public TankFigure() { super(); ((LinearScale) scale).setOrientation(Orientation.VERTICAL); scale.setScaleLineVisible(false); tank = new Tank(); setLayoutManager(new TankLayout()); add(scale, TankLayout.SCALE); add(marker, TankLayout.MARKERS); add(tank, TankLayout.TANK); }
public void layout(IFigure container) { Rectangle area = container.getClientArea(); area.height -= 1; Dimension scaleSize = new Dimension(0, 0); Dimension markerSize = new Dimension(0, 0); if (scale != null) { if (scale.isVisible()) { scaleSize = scale.getPreferredSize(-1, area.height); scale.setBounds(new Rectangle(area.x, area.y, scaleSize.width, scaleSize.height)); } else { scaleSize = scale.getPreferredSize(-1, area.height + 2 * scale.getMargin()); scale.setBounds( new Rectangle(area.x, area.y - scale.getMargin(), scaleSize.width, scaleSize.height)); scaleSize.height = 0; scaleSize.width = 0; } } if (marker != null && marker.isVisible()) { markerSize = marker.getPreferredSize(); marker.setBounds( new Rectangle( area.x + area.width - markerSize.width, marker.getScale().getBounds().y, markerSize.width, markerSize.height)); } if (tank != null) { tank.setBounds( new Rectangle( area.x + scaleSize.width, scale.getValuePosition(scale.getRange().getUpper(), false), area.width - scaleSize.width - markerSize.width, scale.getTickLength() + tank.getLineWidth())); } }