1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.gscg.gameleader.animation2D;
15
16 import java.awt.Color;
17 import java.awt.Dimension;
18 import java.awt.Graphics2D;
19 import java.awt.geom.Rectangle2D;
20 import java.awt.image.ImageObserver;
21 import java.rmi.RemoteException;
22
23 import javax.vecmath.Point2d;
24
25 import nl.tudelft.simulation.dsol.animation.D2.Renderable2DInterface;
26 import nl.tudelft.simulation.dsol.gui.animation2D.GridPanel;
27 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
28 import nl.tudelft.simulation.language.d3.DirectedPoint;
29 import nl.tudelft.simulation.logger.Logger;
30
31 /***
32 * Displays the legend on a remote animation panel.
33 * <p>
34 *
35 * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
36 * Delft, the Netherlands. All rights reserved.
37 *
38 * See for project information <a href="http://www.simulation.tudelft.nl/">
39 * www.simulation.tudelft.nl </a>.
40 *
41 * The source code and binary code of this software is proprietary information
42 * of Delft University of Technology.
43 *
44 * @author <a
45 * href="http://www.tbm.tudelft.nl/webstaf/stijnh/index.htm">Stijn-Pieter
46 * van Houten </a>
47 * @version $Revision: 1.1 $ $Date: 2005/06/16 12:34:02 $
48 * @since 1.0.8
49 */
50 public class DistributedGisLegendRenderable extends GisGraphicsRenderable
51 implements DistributedRenderable2DInterface
52 {
53 /*** the serial version uid */
54 private static final long serialVersionUID = 11L;
55
56 /***
57 * constructs a new DistributedGisLegendRenderable
58 *
59 * @param location the location
60 * @param simulator the simulator
61 */
62 public DistributedGisLegendRenderable(final DirectedPoint location,
63 final SimulatorInterface simulator)
64 {
65 super(location, simulator, null);
66 }
67
68 /***
69 * @see org.gscg.gameleader.animation2D.GisGraphicsRenderable#bindToContext(java.lang.String)
70 */
71 protected void bindToContext(final String contextName)
72 {
73
74 }
75
76 /***
77 * @see nl.tudelft.simulation.dsol.animation.D2.Renderable2DInterface#paint(java.awt.Graphics2D,
78 * java.awt.geom.Rectangle2D, java.awt.Dimension,
79 * java.awt.image.ImageObserver)
80 */
81 public synchronized void paint(final Graphics2D graphics,
82 final Rectangle2D rectangle, final Dimension dimension,
83 final ImageObserver observer)
84 {
85
86 GridPanel animationPanel = (GridPanel) observer;
87
88 double scale = Renderable2DInterface.Util.getScale(animationPanel
89 .getExtent(), animationPanel.getSize());
90
91
92 Point2d screenLocation = null;
93 try
94 {
95 screenLocation = new Point2d(super.locatable.getLocation().x,
96 super.locatable.getLocation().y);
97 } catch (RemoteException remoteException)
98 {
99 Logger.severe(this, "paint", remoteException);
100 }
101
102
103 if (scale >=
104 {
105 graphics.setColor(Color.BLUE);
106 graphics.fillOval((int) screenLocation.x, (int) screenLocation.y,
107 10, 10);
108 graphics.drawString("Manufacturer", (int) screenLocation.x + 25,
109 (int) screenLocation.y + 10);
110 graphics.setColor(Color.RED);
111
112 graphics.fillOval((int) screenLocation.x,
113 (int) screenLocation.y + 15, 10, 10);
114 graphics.drawString("Distributor", (int) screenLocation.x + 25,
115 (int) screenLocation.y + 25);
116
117 graphics.setColor(Color.GREEN);
118 graphics.fillOval((int) screenLocation.x,
119 (int) screenLocation.y + 30, 10, 10);
120 graphics.drawString("Market", (int) screenLocation.x + 25,
121 (int) screenLocation.y + 40);
122 }
123 }
124
125 /***
126 * @see org.gscg.gameleader.animation2D.DistributedRenderable2DInterface#setLocation(nl.tudelft.simulation.language.d3.DirectedPoint)
127 */
128 public void setLocation(final DirectedPoint location)
129 throws RemoteException
130 {
131
132 }
133 }