freemind.view.mindmapview

Class MapView

Implemented Interfaces:
Printable

public class MapView
extends JPanel
implements Printable

This class represents the view of a whole MindMap (in analogy to class JTree).

Nested Class Summary

protected class
MapView.nodesDepthComparator
This class sortes nodes by ascending depth of their paths to root.

Constructor Summary

MapView(MindMap model, Controller controller)

Method Summary

void
centerNode(NodeView node)
Problem: Before scrollRectToVisible is called, the node has the location (0,0), ie.
protected void
collectLabels(NodeView source, HashMap labels)
collect all existing labels in the current map.
void
deselect(NodeView newSelected)
MindMapArrowLink
detectCollision(Point p)
Controller
getController()
int
getMaxNodeWidth()
MindMap
getModel()
Dimension
getPreferredSize()
protected NodeView
getRoot()
NodeView
getSelected()
ArrayList
getSelectedNodesSortedByY()
LinkedList
getSelecteds()
LinkedList
getSelectedsByDepth()
ArrayList
getSelectedsSortedByY()
int
getSiblingMaxLevel()
float
getZoom()
int
getZoomed(int number)
void
initRoot()
boolean
isPrinting()
For nodes, they can ask, whether or not the width must be bigger to prevent the "..." at the output.
boolean
isSelected(NodeView n)
void
makeTheSelected(NodeView newSelected)
Add the node to the selection if it is not yet there, making it the focused selected node.
void
move(KeyEvent e)
void
moveToRoot()
void
paintChildren(Graphics graphics)
P A I N T I N G **
protected void
paintClouds(NodeView source, Graphics graphics, int iterativeLevel)
protected void
paintLinks(NodeView source, Graphics2D graphics, HashMap labels, HashSet LinkAlreadyVisited)
int
print(Graphics graphics, PageFormat pageFormat, int pageIndex)
void
scrollBy(int x, int y)
Scroll the viewport of the map to the south-west, i.e.
void
scrollNodeToVisible(NodeView node)
void
scrollNodeToVisible(NodeView node, int extraWidth)
void
selectAsTheOnlyOneSelected(NodeView newSelected)
Select the node, resulting in only that one being selected.
void
selectBranch(NodeView newlySelectedNodeView, boolean extend)
Select the node and his descendants.
boolean
selectContinuous(NodeView newSelected)
void
setMoveCursor(boolean isHand)
void
setSiblingMaxLevel(int level)
void
setZoom(float zoom)
void
toggleSelected(NodeView newSelected)
Add the node to the selection if it is not yet there, remove it otherwise.

Constructor Details

MapView

public MapView(MindMap model,
               Controller controller)

Method Details

centerNode

public void centerNode(NodeView node)
Problem: Before scrollRectToVisible is called, the node has the location (0,0), ie. the location first gets calculated after the scrollpane is actually scrolled. Thus, as a workaround, I simply call scrollRectToVisible twice, the first time the location of the node is calculated, the second time the scrollPane is actually scrolled.

collectLabels

protected void collectLabels(NodeView source,
                             HashMap labels)
collect all existing labels in the current map.

deselect

public void deselect(NodeView newSelected)

detectCollision

public MindMapArrowLink detectCollision(Point p)

getController

public Controller getController()

getMaxNodeWidth

public int getMaxNodeWidth()

getModel

public MindMap getModel()

getPreferredSize

public Dimension getPreferredSize()

getRoot

protected NodeView getRoot()

getSelected

public NodeView getSelected()

getSelectedNodesSortedByY

public ArrayList getSelectedNodesSortedByY()

getSelecteds

public LinkedList getSelecteds()

getSelectedsByDepth

public LinkedList getSelectedsByDepth()
Returns:
a LinkedList of NodeViews ordered by depth. nodes with greater depth occur first.

getSelectedsSortedByY

public ArrayList getSelectedsSortedByY()

getSiblingMaxLevel

public int getSiblingMaxLevel()

getZoom

public float getZoom()

getZoomed

public int getZoomed(int number)

initRoot

public void initRoot()

isPrinting

public boolean isPrinting()
For nodes, they can ask, whether or not the width must be bigger to prevent the "..." at the output. (Bug of java).

isSelected

public boolean isSelected(NodeView n)

makeTheSelected

public void makeTheSelected(NodeView newSelected)
Add the node to the selection if it is not yet there, making it the focused selected node.

move

public void move(KeyEvent e)

moveToRoot

public void moveToRoot()

paintChildren

public void paintChildren(Graphics graphics)
P A I N T I N G **

paintClouds

protected void paintClouds(NodeView source,
                           Graphics graphics,
                           int iterativeLevel)
Parameters:
iterativeLevel - describes the n-th nested cloud that is to be painted.

paintLinks

protected void paintLinks(NodeView source,
                          Graphics2D graphics,
                          HashMap labels,
                          HashSet LinkAlreadyVisited)

print

public int print(Graphics graphics,
                 PageFormat pageFormat,
                 int pageIndex)

scrollBy

public void scrollBy(int x,
                     int y)
Scroll the viewport of the map to the south-west, i.e. scroll the map itself to the north-east.

scrollNodeToVisible

public void scrollNodeToVisible(NodeView node)

scrollNodeToVisible

public void scrollNodeToVisible(NodeView node,
                                int extraWidth)

selectAsTheOnlyOneSelected

public void selectAsTheOnlyOneSelected(NodeView newSelected)
Select the node, resulting in only that one being selected.

selectBranch

public void selectBranch(NodeView newlySelectedNodeView,
                         boolean extend)
Select the node and his descendants. On extend = false clear up the previous selection. if extend is false, the past selection will be empty. if yes, the selection will extended with this node and its children

selectContinuous

public boolean selectContinuous(NodeView newSelected)

setMoveCursor

public void setMoveCursor(boolean isHand)

setSiblingMaxLevel

public void setSiblingMaxLevel(int level)

setZoom

public void setZoom(float zoom)

toggleSelected

public void toggleSelected(NodeView newSelected)
Add the node to the selection if it is not yet there, remove it otherwise.