Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private PaintableElevator paintableObject;
- private Line2D wallLeftSide = new Line2D.Double();
- private Line2D wallRightSide = new Line2D.Double();
- private Rectangle2D elevator = new Rectangle2D.Double();
- @Override
- public void componentResized (ComponentEvent e)
- {
- wallLeftSide.setLine(new Point2D.Double(0, changeYCoordsOrigin(getHeight() * paintableObject.getTotalHeight())), new Point2D.Double(0, getWidth()));
- wallRightSide.setLine(new Point2D.Double(getWidth(), changeYCoordsOrigin(getHeight() * paintableObject.getTotalHeight())), new Point2D.Double(getWidth(), getHeight()));
- elevator.setRect(0, changeYCoordsOrigin(getHeight() * paintableObject.getHeightInShaft()), getWidth(), paintableObject.getCabinHeight() * getHeight() *-1);
- }
- public double changeYCoordsOrigin (double coord)
- {
- return getHeight() - coord;
- }
- @Override
- public void setHeigth (double height)
- {
- elevator.setRect(0, getHeight() * height, getWidth(), paintableObject.getCabinHeight());
- repaint();
- }
- @Override
- public void paint (Graphics g)
- {
- if (g instanceof Graphics2D)
- {
- Graphics2D g2 = (Graphics2D) g;
- g2.draw(wallLeftSide);
- g2.draw(wallRightSide);
- g2.setBackground(Color.gray);
- g2.draw(elevator);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement