~ubuntu-branches/ubuntu/utopic/freemind/utopic

« back to all changes in this revision

Viewing changes to freemind/freemind/view/mindmapview/RightNodeViewLayout.java

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-01-03 14:19:19 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100103141919-m5az7dkicy21hqop
Tags: 0.9.0~rc6+dfsg-1ubuntu1
* Merge from Debian unstable (LP: #182927), remaining changes:
  - debian/copyright: add license/copyright for
    freemind/freemind/main/ExampleFileFilter.java

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*FreeMind - A Program for creating and viewing Mindmaps
 
2
*Copyright (C) 2000-2006 Joerg Mueller, Daniel Polansky, Christian Foltin, Dimitri Polivaev and others.
 
3
*
 
4
*See COPYING for Details
 
5
*
 
6
*This program is free software; you can redistribute it and/or
 
7
*modify it under the terms of the GNU General Public License
 
8
*as published by the Free Software Foundation; either version 2
 
9
*of the License, or (at your option) any later version.
 
10
*
 
11
*This program is distributed in the hope that it will be useful,
 
12
*but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
*GNU General Public License for more details.
 
15
*
 
16
*You should have received a copy of the GNU General Public License
 
17
*along with this program; if not, write to the Free Software
 
18
*Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
*/
 
20
/*
 
21
 * Created on 05.06.2005
 
22
 *
 
23
 */
 
24
package freemind.view.mindmapview;
 
25
 
 
26
import java.awt.Container;
 
27
import java.awt.Dimension;
 
28
import java.awt.Point;
 
29
 
 
30
import javax.swing.JComponent;
 
31
import javax.swing.JLabel;
 
32
 
 
33
import freemind.main.Tools;
 
34
 
 
35
/**
 
36
 * @author dimitri
 
37
 * 05.06.2005
 
38
 */
 
39
public class RightNodeViewLayout extends NodeViewLayoutAdapter {
 
40
    static private RightNodeViewLayout instance = null;
 
41
    
 
42
    protected void layout() {
 
43
        final int contentHeight = getChildContentHeight(false);
 
44
        int childVerticalShift =  getChildVerticalShift(false);
 
45
        final int childHorizontalShift = getChildHorizontalShift();
 
46
        
 
47
        if(getView().isContentVisible()){
 
48
            getContent().setVisible(true);
 
49
            final Dimension contentPreferredSize = getContent().getPreferredSize();
 
50
            final int x = Math.max(getSpaceAround(), -contentPreferredSize.width -childHorizontalShift);
 
51
            childVerticalShift += (contentPreferredSize.height - contentHeight) / 2;
 
52
            final int y = Math.max(getSpaceAround(), - childVerticalShift );
 
53
            getContent().setBounds(x, y , contentPreferredSize.width, contentPreferredSize.height);
 
54
        }
 
55
        else{
 
56
            getContent().setVisible(false);
 
57
            final int x = Math.max(getSpaceAround(), -childHorizontalShift);
 
58
            final int y = Math.max(getSpaceAround(), - childVerticalShift );
 
59
            getContent().setBounds(x, y, 0, contentHeight);
 
60
        }
 
61
        
 
62
        placeRightChildren(childVerticalShift);
 
63
    }
 
64
 
 
65
   static RightNodeViewLayout getInstance() {
 
66
        if (instance == null) instance = new RightNodeViewLayout();
 
67
        return instance;
 
68
    }
 
69
 
 
70
public void layoutNodeMotionListenerView(NodeMotionListenerView view) {
 
71
    NodeView movedView = view.getMovedView();
 
72
    final JComponent content = movedView.getContent();
 
73
    location.x = -LISTENER_VIEW_WIDTH;
 
74
    location.y = 0;
 
75
    Tools.convertPointToAncestor(content, location, view.getParent());  
 
76
    view.setLocation(location);
 
77
    view.setSize(LISTENER_VIEW_WIDTH, content.getHeight());
 
78
}
 
79
 
 
80
public Point getMainViewOutPoint(NodeView view, NodeView targetView, Point destinationPoint) {
 
81
    final MainView mainView = view.getMainView();
 
82
    return mainView.getRightPoint();
 
83
}
 
84
 
 
85
public Point getMainViewInPoint(NodeView view) {
 
86
    final MainView mainView = view.getMainView();
 
87
    return mainView.getLeftPoint();
 
88
}
 
89
 
 
90
 
 
91
}