⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nodeview.java

📁 思维导图(Mind Mapping)以放射性思考(Radiant Thinking)为基础的收放自如方式
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
      super. requestFocus();   }   /** draw folding symbol*/		public void paintFoldingMark(Graphics2D g){ 	}    public void paint(Graphics graphics) {        // background color starts here, fc. 9.11.2003: todo//           graphics.setColor(Color.yellow);//           graphics.fillRect(0,0,getWidth(), getHeight());          // background color ends here, fc. 9.11.2003: todo	super.paint(graphics);    }    public void paintSelected(Graphics2D graphics, Dimension size) {		if (this.isSelected()) {			paintBackground(graphics, size, getSelectedColor());			//g.drawRect(0,0,size.width-1, size.height-2);		} else if (getModel().getBackgroundColor() != null) {			paintBackground(graphics, size, getModel().getBackgroundColor());		}//		if (this.isSelected()) {//			paintBackground(graphics, size, getSelectedColor());//			//g.drawRect(0,0,size.width-1, size.height-2);//		} /*else*///		if  (true){//			Dimension newSize = size;//			newSize.height -= 5;//			newSize.width -= 5;//			paintBackground(graphics, newSize, (getModel().getBackgroundColor() != null)?getModel().getBackgroundColor():Color.WHITE);//		}    }	protected void paintBackground(Graphics2D graphics, Dimension size, Color color) {		graphics.setColor(color);		graphics.fillRect(0,0,size.width, size.height);			}   public void paintDragOver(Graphics2D graphics, Dimension size) {        if (isDraggedOver == DRAGGED_OVER_SON) {           if (isLeft()) {              graphics.setPaint( new GradientPaint(size.width*3/4,0,map.getBackground(), size.width/4, 0, dragColor));              graphics.fillRect(0, 0, size.width*3/4, size.height-1); }           else {              graphics.setPaint( new GradientPaint(size.width/4,0,map.getBackground(), size.width*3/4, 0, dragColor));              graphics.fillRect(size.width/4, 0, size.width-1, size.height-1); }       	}        if (isDraggedOver == DRAGGED_OVER_SIBLING) {            graphics.setPaint( new GradientPaint(0,size.height*3/5,map.getBackground(), 0, size.height/5, dragColor));            graphics.fillRect(0, 0, size.width-1, size.height-1);	}    }     //    // get/set methods    //    /**    * Calculates the tree height increment because of the clouds.    */	public int getAdditionalCloudHeigth() {		MindMapCloud cloud = getModel().getCloud();		if( cloud!= null) { 			return CloudView.getAdditionalHeigth(cloud, this);		} else {           			return 0;		}	}     protected boolean isSelected() {	return (getMap().isSelected(this));    }    /**Is the node left of root?*/    public boolean isLeft() {        if(getModel().isLeft() == null)            return true;        return getModel().isLeft().getValue();    }    protected void setLeft(boolean left) {        //this.left = left;        getModel().setLeft(left);    }	//     public boolean isLeftDefault() {//         return getModel().isLeft() == null;//     }        protected void setModel( MindMapNode model ) {	this.model = model;    }    MapView getMap() {	return map;    }    protected void setMap( MapView map ) {	this.map = map;    }    EdgeView getEdge() {	return edge;    }    void setEdge(EdgeView edge) {	this.edge = edge;    }    protected NodeView getParentView() {	return getModel().getParentNode().getViewer();    }    /**     * This method returns the NodeViews that are children of this node.     */    public LinkedList getChildrenViews() {	LinkedList childrenViews = new LinkedList();	ListIterator it = getModel().childrenUnfolded();	if (it != null) {           while(it.hasNext()) {              NodeView view = ((MindMapNode)it.next()).getViewer();              if (view != null) { // Visible view                 childrenViews.add(view); // child.getViewer() );              }           }        }        return childrenViews;    }        protected LinkedList getSiblingViews() {	return getParentView().getChildrenViews();    }    /**     * Returns the Point where the OutEdge     * should leave the Node.     * THIS SHOULD BE DECLARED ABSTRACT AND BE DONE IN BUBBLENODEVIEW ETC.     */    Point getOutPoint() {	Dimension size = getSize();	if( isRoot() ) {	    return new Point(getLocation().x + size.width, getLocation().y + size.height / 2);	} else if( isLeft() ) {	    return new Point(getLocation().x, getLocation().y + size.height - 2);	} else {	    return new Point(getLocation().x + size.width, getLocation().y + size.height - 2);	}     }        /* fc, 26.06.2005 */    /** Returns the point the edge should start given the point of the child node      * that should be connected.     * @param destinationPoint the outpoint should point in the direction of destinationPoint      * @param isLeft TODO     * @return     */    Point getOutPoint(Point destinationPoint, boolean isLeft) {        return getOutPoint();    }    /* end fc, 26.06.2005 */        /**     * Returns the Point where the InEdge     * should arrive the Node.     * THIS SHOULD BE DECLARED ABSTRACT AND BE DONE IN BUBBLENODEVIEW ETC.     */    Point getInPoint() {	Dimension size = getSize();	if( isRoot() ) {	    return new Point(getLocation().x, getLocation().y + size.height / 2);	} else if( isLeft() ) {	    return new Point(getLocation().x + size.width, getLocation().y + size.height - 2);	} else {	    return new Point(getLocation().x, getLocation().y + size.height - 2);	}     }    /**     * Returns the Point where the Links      * should arrive the Node.     * THIS SHOULD BE DECLARED ABSTRACT AND BE DONE IN BUBBLENODEVIEW ETC.     */    public Point getLinkPoint(Point declination) {		Dimension size = getSize();		int x, y;		if(declination != null){			x = getMap().getZoomed(declination.x);			y = getMap().getZoomed(declination.y);		}		else{			x = 1;			y = 0;		}		if( isRoot() || isLeft()) {			x = -x;		}		if(y != 0){			double ctgRect = Math.abs((double)size.width / size.height);			double ctgLine = Math.abs((double)x / y);			int absLinkX, absLinkY;			if(ctgRect > ctgLine){				absLinkX = Math.abs(x*size.height / (2 * y));				absLinkY = size.height / 2;			}			else{				absLinkX = size.width / 2;				absLinkY = Math.abs(y*size.width / (2 * x));			}			return new Point(getLocation().x + size.width / 2 + (x>0 ? absLinkX : -absLinkX), 							getLocation().y + size.height / 2 + (y>0 ? absLinkY : -absLinkY));			}		else{			return new Point(getLocation().x + (x>0 ? size.width:0), 			                 getLocation().y + (size.height / 2));			}    }    /**     * Returns the relative position of the Edge.	 * This is used by bold edge to know how to shift the line.     */    int getAlignment() {	if( isRoot() )	    return ALIGN_CENTER;	return ALIGN_BOTTOM;    }	    //    // Navigation    //    protected NodeView getNextPage() {      if (isRoot()) {        return this; // I'm root      }      NodeView sibling = getNextSibling();      if (sibling == this) {        return this; // at the end      }//      if (sibling.getParentView() != this.getParentView()) {//        return sibling; // sibling on another page (has different parent)//      }      NodeView nextSibling = sibling.getNextSibling();      while (nextSibling != sibling               && sibling.getParentView() == nextSibling.getParentView()) {        sibling = nextSibling;        nextSibling = nextSibling.getNextSibling();      }      return sibling; // last on the page    }          protected NodeView getPreviousPage() {      if (isRoot()) {        return this; // I'm root      }      NodeView sibling = getPreviousSibling();      if (sibling == this) {        return this; // at the end      }//      if (sibling.getParentView() != this.getParentView()) {//        return sibling; // sibling on another page (has different parent)//      }      NodeView previousSibling = sibling.getPreviousSibling();      while (previousSibling != sibling               && sibling.getParentView() == previousSibling.getParentView()) {        sibling = previousSibling;        previousSibling = previousSibling.getPreviousSibling();      }      return sibling; // last on the page    }        protected NodeView getNextSibling() {      NodeView sibling;      NodeView nextSibling = this;            // get next sibling even in higher levels      for (sibling = this; !sibling.isRoot(); sibling = sibling.getParentView()) {         nextSibling = sibling.getNextSiblingSingle();        if (sibling != nextSibling) {          break; // found sibling        }      }            if (sibling.isRoot()) {        return this;  // didn't find (we are at the end)      }            // we have the nextSibling, search in childs      // untill: leaf, closed node, max level      sibling = nextSibling;      while (sibling.getModel().getNodeLevel() < getMap().getSiblingMaxLevel()) {        // can we drill down?        if (sibling.getChildrenViews().size() <= 0) {          break; // no        }        sibling = (NodeView)(sibling.getChildrenViews().getFirst());      }      return sibling;    }    protected NodeView getPreviousSibling() {      NodeView sibling;      NodeView previousSibling = this;            // get Previous sibling even in higher levels      for (sibling = this; !sibling.isRoot(); sibling = sibling.getParentView()) {         previousSibling = sibling.getPreviousSiblingSingle();        if (sibling != previousSibling) {          break; // found sibling        }      }            if (sibling.isRoot()) {        return this;  // didn't find (we are at the end)      }            // we have the PreviousSibling, search in childs      // untill: leaf, closed node, max level      sibling = previousSibling;      while (sibling.getModel().getNodeLevel() < getMap().getSiblingMaxLevel()) {        // can we drill down?        if (sibling.getChildrenViews().size() <= 0) {          break; // no        }        sibling = (NodeView)(sibling.getChildrenViews().getLast());      }      return sibling;    }    protected NodeView getNextSiblingSingle() {	LinkedList v = null;	if (getParentView().isRoot()) {	    if (this.isLeft()) {		v = ((RootNodeView)getParentView()).getLeft();	    } else {		v = ((RootNodeView)getParentView()).getRight();	    }	} else {	    v = getParentView().getChildrenViews();	}		NodeView sibling;	if (v.size()-1 == v.indexOf(this)) { //this is last, return first//	    sibling = (NodeView)v.getFirst(); // loop            sibling = this;	} else {	    sibling = (NodeView)v.get(v.indexOf(this)+1);	}	return sibling;    }    protected NodeView getPreviousSiblingSingle() {	LinkedList v = null;	if (getParentView().isRoot()) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -