1
/*FreeMind - A Program for creating and viewing Mindmaps
2
*Copyright (C) 2000-2006 Joerg Mueller, Daniel Polansky, Christian Foltin, Dimitri Polivaev and others.
4
*See COPYING for Details
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.
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.
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.
21
* Created on 05.06.2005
24
package freemind.view.mindmapview;
26
import java.awt.Container;
27
import java.awt.Dimension;
28
import java.awt.Point;
30
import javax.swing.JComponent;
31
import javax.swing.JLabel;
33
import freemind.main.Tools;
39
public class RightNodeViewLayout extends NodeViewLayoutAdapter {
40
static private RightNodeViewLayout instance = null;
42
protected void layout() {
43
final int contentHeight = getChildContentHeight(false);
44
int childVerticalShift = getChildVerticalShift(false);
45
final int childHorizontalShift = getChildHorizontalShift();
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);
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);
62
placeRightChildren(childVerticalShift);
65
static RightNodeViewLayout getInstance() {
66
if (instance == null) instance = new RightNodeViewLayout();
70
public void layoutNodeMotionListenerView(NodeMotionListenerView view) {
71
NodeView movedView = view.getMovedView();
72
final JComponent content = movedView.getContent();
73
location.x = -LISTENER_VIEW_WIDTH;
75
Tools.convertPointToAncestor(content, location, view.getParent());
76
view.setLocation(location);
77
view.setSize(LISTENER_VIEW_WIDTH, content.getHeight());
80
public Point getMainViewOutPoint(NodeView view, NodeView targetView, Point destinationPoint) {
81
final MainView mainView = view.getMainView();
82
return mainView.getRightPoint();
85
public Point getMainViewInPoint(NodeView view) {
86
final MainView mainView = view.getMainView();
87
return mainView.getLeftPoint();