|
@@ -55,14 +55,16 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
|
|
|
|
|
|
public int getScaledX( int x )
|
|
|
{
|
|
|
- double scale = Math.min( (getWidth()-50) / (double)getVirtualWidth(), (getHeight()-50) / (double)getVirtualHeight());
|
|
|
+ double scale1 = Math.min( (getWidth()) / (double)getWidthOfNeededArea(), (getHeight()) / (double)getHeightOfNeededArea());
|
|
|
+ double scale = Math.min( (getWidth()-50*scale1) / (double)getWidthOfNeededArea(), (getHeight()-50*scale1) / (double)getHeightOfNeededArea());
|
|
|
x *= scale;
|
|
|
return x;
|
|
|
}
|
|
|
|
|
|
public int getScaledY( int y )
|
|
|
{
|
|
|
- double scale = Math.min( (getWidth()-50) / (double)getVirtualWidth(), (getHeight()-50) / (double)getVirtualHeight());
|
|
|
+ double scale1 = Math.min( (getWidth()) / (double)getWidthOfNeededArea(), (getHeight()) / (double)getHeightOfNeededArea());
|
|
|
+ double scale = Math.min( (getWidth()-50*scale1) / (double)getWidthOfNeededArea(), (getHeight()-50*scale1) / (double)getHeightOfNeededArea());
|
|
|
y *= scale;
|
|
|
return y;
|
|
|
}
|
|
@@ -76,7 +78,12 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
|
|
|
"<br>Shift: " + model.getShift( layout ) + "</html>" );
|
|
|
}
|
|
|
else
|
|
|
- setToolTipText( "Name: " + model.toString() );
|
|
|
+ {
|
|
|
+ setToolTipText( "<html>Name: " + model.toString() +
|
|
|
+ "<br>result X: " + model.getX( LayoutType.COMBINED ) +
|
|
|
+ "<br>other layouts: [" + model.getX( LayoutType.TOP_BOTTOM_LEFT ) + "," + model.getX( LayoutType.TOP_BOTTOM_RIGHT ) + ","
|
|
|
+ + model.getX( LayoutType.BOTTOM_TOP_LEFT ) + "," + model.getX( LayoutType.BOTTOM_TOP_RIGHT ) + "]</html>" );
|
|
|
+ }
|
|
|
for( Component c : getComponents() )
|
|
|
{
|
|
|
if( !(c instanceof NodeView) )
|
|
@@ -88,16 +95,18 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
|
|
|
public int getXOffset()
|
|
|
{
|
|
|
int x = 0;
|
|
|
- double scale = Math.min( (getWidth()-50) / (double)getVirtualWidth(), (getHeight()-50) / (double)getVirtualHeight());
|
|
|
- x += (getWidth()-50) / 2 - (getVirtualWidth() * scale ) / 2 + 25;
|
|
|
+ double scale1 = Math.min( (getWidth()) / (double)getWidthOfNeededArea(), (getHeight()) / (double)getHeightOfNeededArea());
|
|
|
+ double scale = Math.min( (getWidth()-50*scale1) / (double)getWidthOfNeededArea(), (getHeight()-50*scale1) / (double)getHeightOfNeededArea());
|
|
|
+ x += (getWidth()-50) / 2 - (getWidthOfNeededArea() * scale ) / 2 + 25;
|
|
|
return x;
|
|
|
}
|
|
|
|
|
|
public int getYOffset()
|
|
|
{
|
|
|
int y = 0;
|
|
|
- double scale = Math.min( (getWidth()-50) / (double)getVirtualWidth(), (getHeight()-50) / (double)getVirtualHeight());
|
|
|
- y += (getHeight()-50) / 2 - (getVirtualHeight() * scale ) / 2 + 25;
|
|
|
+ double scale1 = Math.min( (getWidth()) / (double)getWidthOfNeededArea(), (getHeight()) / (double)getHeightOfNeededArea());
|
|
|
+ double scale = Math.min( (getWidth()-50*scale1) / (double)getWidthOfNeededArea(), (getHeight()-50*scale1) / (double)getHeightOfNeededArea());
|
|
|
+ y += (getHeight()-50) / 2 - (getHeightOfNeededArea() * scale ) / 2 + 25;
|
|
|
return y;
|
|
|
}
|
|
|
|
|
@@ -109,6 +118,34 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
|
|
|
return originalHeight;
|
|
|
}
|
|
|
|
|
|
+ private int getWidthOfNeededArea() {
|
|
|
+ int max = 0;
|
|
|
+ double min = Double.POSITIVE_INFINITY;
|
|
|
+ for( Component c : getComponents() )
|
|
|
+ {
|
|
|
+ if( c instanceof NodeView )
|
|
|
+ {
|
|
|
+ max = Math.max( max, ((NodeView)c).getVirtualX() + ((NodeView)c).getOriginalWidth() );
|
|
|
+ min = Math.min( ((AnnimatedView)c).getVirtualX(), min);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return max - (int)min;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int getHeightOfNeededArea() {
|
|
|
+ int max = 0;
|
|
|
+ double min = Double.POSITIVE_INFINITY;
|
|
|
+ for( Component c : getComponents() )
|
|
|
+ {
|
|
|
+ if( c instanceof NodeView )
|
|
|
+ {
|
|
|
+ max = Math.max( max, ((NodeView)c).getVirtualY() + ((NodeView)c).getOriginalHeight() );
|
|
|
+ min = Math.min( ((AnnimatedView)c).getVirtualY(), min);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return max - (int)min;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void doLayout() {
|
|
|
double minX = Double.POSITIVE_INFINITY;
|
|
@@ -120,9 +157,10 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
|
|
|
}
|
|
|
int x = 0;
|
|
|
int y = 0;
|
|
|
- double scale = Math.min( (getWidth()-50) / (double)getVirtualWidth(), (getHeight()-50) / (double)getVirtualHeight());
|
|
|
- y += (getHeight()-50) / 2 - (getVirtualHeight() * scale ) / 2 + 25;
|
|
|
- x += (getWidth()-50) / 2 - (getVirtualWidth() * scale ) / 2 + 25;
|
|
|
+ double scale1 = Math.min( (getWidth()) / (double)getWidthOfNeededArea(), (getHeight()) / (double)getHeightOfNeededArea());
|
|
|
+ double scale = Math.min( (getWidth()-50*scale1) / (double)getWidthOfNeededArea(), (getHeight()-50*scale1) / (double)getHeightOfNeededArea());
|
|
|
+ x += (getWidth()) / 2 - (getWidthOfNeededArea() * scale ) / 2;
|
|
|
+ y += (getHeight()) / 2 - (getHeightOfNeededArea() * scale ) / 2;
|
|
|
for( Component c : getComponents() )
|
|
|
{
|
|
|
if( !(c instanceof AnnimatedView) )
|
|
@@ -152,8 +190,9 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
|
|
|
minX = Math.min( ((AnnimatedView)c).getVirtualX(), minX);
|
|
|
}
|
|
|
int x = 0;
|
|
|
- double scale = Math.min( (getWidth()-50) / (double)getVirtualWidth(), (getHeight()-50) / (double)getVirtualHeight());
|
|
|
- x += (getWidth()-50) / 2 - (getVirtualWidth() * scale ) / 2 + 25;
|
|
|
+ double scale1 = Math.min( (getWidth()) / (double)getWidthOfNeededArea(), (getHeight()) / (double)getHeightOfNeededArea());
|
|
|
+ double scale = Math.min( (getWidth()-50*scale1) / (double)getWidthOfNeededArea(), (getHeight()-50*scale1) / (double)getHeightOfNeededArea());
|
|
|
+ x += (getWidth()-50) / 2 - (getWidthOfNeededArea() * scale ) / 2 + 25;
|
|
|
for( Component c : getComponents() )
|
|
|
{
|
|
|
if( c instanceof NodeView )
|