|
@@ -49,7 +49,15 @@ public class NodeView extends JPanel {
|
|
return;
|
|
return;
|
|
double scale = Math.min( (double)super.getWidth() / (int)model.getWidth( layout ), (double)super.getHeight() / (int)model.getHeight( layout ));
|
|
double scale = Math.min( (double)super.getWidth() / (int)model.getWidth( layout ), (double)super.getHeight() / (int)model.getHeight( layout ));
|
|
((Graphics2D)g).scale( scale, scale );
|
|
((Graphics2D)g).scale( scale, scale );
|
|
- paintComponent( g );
|
|
|
|
|
|
+ int x = 0;
|
|
|
|
+ int y = 0;
|
|
|
|
+ int width = (int)(super.getWidth() / scale);
|
|
|
|
+ int height = (int)(super.getHeight() / scale);
|
|
|
|
+ if( scale == (double)super.getWidth() / (int)model.getWidth( layout ) )
|
|
|
|
+ y += (super.getHeight() - (model.getHeight( layout ) * scale )) / scale / 2;
|
|
|
|
+ if( scale == (double)super.getHeight() / (int)model.getHeight( layout ) )
|
|
|
|
+ x += (super.getWidth() - (model.getWidth( layout ) * scale )) / scale / 2;
|
|
|
|
+ paintComponent( g.create( x, y, width, height ) );
|
|
double minX = Double.POSITIVE_INFINITY;
|
|
double minX = Double.POSITIVE_INFINITY;
|
|
for( Component c : getComponents() )
|
|
for( Component c : getComponents() )
|
|
{
|
|
{
|
|
@@ -58,8 +66,8 @@ public class NodeView extends JPanel {
|
|
for( Component c : getComponents() )
|
|
for( Component c : getComponents() )
|
|
{
|
|
{
|
|
c.paint( g.create(
|
|
c.paint( g.create(
|
|
- c.getLocation().x + 25 - (int)minX,
|
|
|
|
- c.getLocation().y + 25,
|
|
|
|
|
|
+ c.getLocation().x + 25 - (int)minX + x,
|
|
|
|
+ c.getLocation().y + 25 + y,
|
|
Math.min( (int)model.getWidth( layout ) - 25, c.getPreferredSize().width + Math.abs(c.getLocation().x) + 25 ),
|
|
Math.min( (int)model.getWidth( layout ) - 25, c.getPreferredSize().width + Math.abs(c.getLocation().x) + 25 ),
|
|
Math.min( (int)model.getHeight( layout ) - 25, c.getPreferredSize().height + Math.abs(c.getLocation().y) + 25 ) ) );
|
|
Math.min( (int)model.getHeight( layout ) - 25, c.getPreferredSize().height + Math.abs(c.getLocation().y) + 25 ) ) );
|
|
}
|
|
}
|