1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.elementclass.operationsymbols;
14 import java.awt.Color;
15 import java.awt.geom.AffineTransform;
16 import java.awt.geom.Rectangle2D;
18 import org.simantics.g2d.diagram.handler.Topology.Terminal;
19 import org.simantics.g2d.element.ElementClass;
20 import org.simantics.g2d.element.ElementUtils;
21 import org.simantics.g2d.element.IElement;
22 import org.simantics.g2d.element.SceneGraphNodeKey;
23 import org.simantics.g2d.element.handler.AdditionalColor;
24 import org.simantics.g2d.element.handler.BorderColor;
25 import org.simantics.g2d.element.handler.Clickable;
26 import org.simantics.g2d.element.handler.Clickable.PressStatus;
27 import org.simantics.g2d.element.handler.FillColor;
28 import org.simantics.g2d.element.handler.SceneGraph;
29 import org.simantics.g2d.element.handler.impl.AdditionalColorImpl;
30 import org.simantics.g2d.element.handler.impl.BorderColorImpl;
31 import org.simantics.g2d.element.handler.impl.DefaultTransform;
32 import org.simantics.g2d.element.handler.impl.FillColorImpl;
33 import org.simantics.g2d.element.handler.impl.FixedSize;
34 import org.simantics.g2d.element.handler.impl.Resizeable;
35 import org.simantics.g2d.element.handler.impl.StaticTerminals;
36 import org.simantics.g2d.element.handler.impl.TerminalImpl;
37 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.BoilerSymbol;
38 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.BoilerSymbol2;
39 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.ChimneySymbol;
40 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.CompressorSymbol;
41 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.ControlValveSymbol;
42 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.GeneratorSymbol;
43 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.HeatExchangerSymbol;
44 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.NoSpinSymbol;
45 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.PumpSymbol;
46 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.ShutoffValveSymbol;
47 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.SwitchSymbol;
48 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.Tank2Symbol;
49 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.TankSymbol;
50 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.ThreeWayValveSymbol;
51 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.TurbineSymbol;
52 import org.simantics.g2d.elementclass.operationsymbols.OperationSymbols.VoltageTransformerSymbol;
53 import org.simantics.g2d.image.Image;
54 import org.simantics.g2d.utils.geom.DirectionSet;
55 import org.simantics.scenegraph.Node;
56 import org.simantics.scenegraph.g2d.G2DParentNode;
57 import org.simantics.utils.datastructures.hints.IHintContext.Key;
60 * Operation symbol handlers.
62 * @author Toni Kalajainen
64 public class OperationClasses {
66 static final FillColor FILL_COLOR_HANDLER = FillColorImpl.handlerOf(Color.WHITE);
67 static final BorderColor BORDER_COLOR_HANDLER = BorderColorImpl.handlerOf(Color.BLACK);
68 static final AdditionalColor ADDITIONAL_COLOR_HANDLER = AdditionalColorImpl.handlerOf(Color.GREEN);
70 public static final Terminal TERMINAL_IN = new TerminalImpl();
71 public static final Terminal TERMINAL_OUT = new TerminalImpl();
73 public static ElementClass BOILER_CLASS =
75 DefaultTransform.INSTANCE,
79 FixedSize.of(-10, 0, 20, 125),
80 StaticTerminals.compile(
81 TERMINAL_IN, 0.0, -BoilerSymbol.DIM*3, DirectionSet.N,
82 TERMINAL_OUT, 0.0, BoilerSymbol.DIM*3, DirectionSet.S
85 public static ElementClass BOILER_BUTTON_CLASS =
88 DefaultTransform.INSTANCE,
92 FixedSize.of(-10, 0, 20, 125),
93 StaticTerminals.compile(
94 TERMINAL_IN, 0.0, -BoilerSymbol.DIM*3, DirectionSet.N,
95 TERMINAL_OUT, 0.0, BoilerSymbol.DIM*3, DirectionSet.S
98 public static ElementClass NO_SPIN_CLASS =
100 DefaultTransform.INSTANCE,
101 NoSpinPaint.INSTANCE,
103 BORDER_COLOR_HANDLER,
104 FixedSize.of(NoSpinSymbol.BOUNDS),
105 StaticTerminals.compile(
106 TERMINAL_IN, 0.0, 0.0, DirectionSet.NESW
109 public static ElementClass NO_SPIN_BUTTON_CLASS =
110 ElementClass.compile(
112 DefaultTransform.INSTANCE,
113 NoSpinPaint.INSTANCE,
115 BORDER_COLOR_HANDLER,
116 FixedSize.of(NoSpinSymbol.BOUNDS),
117 StaticTerminals.compile(
118 TERMINAL_IN, 0.0, 0.0, DirectionSet.NESW
121 public static ElementClass COMPRESSOR_CLASS =
122 ElementClass.compile(
123 DefaultTransform.INSTANCE,
124 CompressorPaint.INSTANCE,
126 BORDER_COLOR_HANDLER,
127 FixedSize.of(CompressorSymbol.BOUNDS),
128 StaticTerminals.compile(
129 TERMINAL_IN, 0.0, 0.0, DirectionSet.NESW
132 public static ElementClass COMPRESSOR_BUTTON_CLASS =
133 ElementClass.compile(
135 DefaultTransform.INSTANCE,
136 CompressorPaint.INSTANCE,
138 BORDER_COLOR_HANDLER,
139 FixedSize.of(CompressorSymbol.BOUNDS),
140 StaticTerminals.compile(
141 TERMINAL_IN, 0.0, 0.0, DirectionSet.NESW
144 public static ElementClass CONTROLVALVE_CLASS =
145 ElementClass.compile(
146 DefaultTransform.INSTANCE,
147 ControlValvePaint.INSTANCE,
149 BORDER_COLOR_HANDLER,
150 FixedSize.of(ControlValveSymbol.BOUNDS),
151 StaticTerminals.compile(
152 TERMINAL_IN, -ControlValveSymbol.D, 0.0, DirectionSet.N,
153 TERMINAL_OUT, ControlValveSymbol.D, 0.0, DirectionSet.S
156 public static ElementClass CONTROLVALVE_BUTTON_CLASS =
157 ElementClass.compile(
159 DefaultTransform.INSTANCE,
160 ControlValvePaint.INSTANCE,
162 BORDER_COLOR_HANDLER,
163 FixedSize.of(ControlValveSymbol.BOUNDS),
164 StaticTerminals.compile(
165 TERMINAL_IN, -ControlValveSymbol.D, 0.0, DirectionSet.N,
166 TERMINAL_OUT, ControlValveSymbol.D, 0.0, DirectionSet.S
169 public static ElementClass THREEWAYVALVE_CLASS =
170 ElementClass.compile(
171 DefaultTransform.INSTANCE,
172 ThreeWayValvePaint.INSTANCE,
174 BORDER_COLOR_HANDLER,
175 FixedSize.of(ControlValveSymbol.BOUNDS),
176 StaticTerminals.compile(
177 TERMINAL_IN, -ThreeWayValveSymbol.D, 0.0, DirectionSet.N,
178 TERMINAL_OUT, ThreeWayValveSymbol.D, 0.0, DirectionSet.S
181 public static ElementClass THREEWAYVALVE_BUTTON_CLASS =
182 ElementClass.compile(
184 DefaultTransform.INSTANCE,
185 ThreeWayValvePaint.INSTANCE,
187 BORDER_COLOR_HANDLER,
188 FixedSize.of(ControlValveSymbol.BOUNDS),
189 StaticTerminals.compile(
190 TERMINAL_IN, -ThreeWayValveSymbol.D, 0.0, DirectionSet.N,
191 TERMINAL_OUT, ThreeWayValveSymbol.D, 0.0, DirectionSet.S
194 public static ElementClass HEATEXCHANGER_CLASS =
195 ElementClass.compile(
196 DefaultTransform.INSTANCE,
197 HeatExchangerPaint.INSTANCE,
199 BORDER_COLOR_HANDLER,
200 FixedSize.of(HeatExchangerSymbol.BOUNDS),
201 StaticTerminals.compile(
202 TERMINAL_IN, HeatExchangerSymbol.BOUNDS.getMinX(), HeatExchangerSymbol.BOUNDS.getMaxY()*0.5, DirectionSet.SW,
203 TERMINAL_OUT, HeatExchangerSymbol.BOUNDS.getMaxX(), HeatExchangerSymbol.BOUNDS.getMinY()*0.5, DirectionSet.NE
206 public static ElementClass HEATEXCHANGER_BUTTON_CLASS =
207 ElementClass.compile(
209 DefaultTransform.INSTANCE,
210 HeatExchangerPaint.INSTANCE,
212 BORDER_COLOR_HANDLER,
213 FixedSize.of(HeatExchangerSymbol.BOUNDS),
214 StaticTerminals.compile(
215 TERMINAL_IN, HeatExchangerSymbol.BOUNDS.getMinX(), HeatExchangerSymbol.BOUNDS.getMaxY(), DirectionSet.SW,
216 TERMINAL_OUT, HeatExchangerSymbol.BOUNDS.getMaxX(), HeatExchangerSymbol.BOUNDS.getMinY(), DirectionSet.NE
219 public static ElementClass PUMP_CLASS =
220 ElementClass.compile(
221 DefaultTransform.INSTANCE,
224 BORDER_COLOR_HANDLER,
225 FixedSize.of(PumpSymbol.BOUNDS),
226 StaticTerminals.compile(
227 TERMINAL_IN, -PumpSymbol.D2, 0.0, DirectionSet.N,
228 TERMINAL_OUT, PumpSymbol.D2, 0.0, DirectionSet.S
231 public static ElementClass PUMP_BUTTON_CLASS =
232 ElementClass.compile(
234 DefaultTransform.INSTANCE,
237 BORDER_COLOR_HANDLER,
238 FixedSize.of(PumpSymbol.BOUNDS),
239 StaticTerminals.compile(
240 TERMINAL_IN, -PumpSymbol.D2, 0.0, DirectionSet.N,
241 TERMINAL_OUT, PumpSymbol.D2, 0.0, DirectionSet.S
244 public static ElementClass SHUTOFFVALVE_CLASS =
245 ElementClass.compile(
246 DefaultTransform.INSTANCE,
247 ShutoffValvePaint.INSTANCE,
249 BORDER_COLOR_HANDLER,
250 FixedSize.of(ShutoffValveSymbol.SHAPE.getBounds()),
251 StaticTerminals.compile(
252 TERMINAL_IN, -ShutoffValveSymbol.DIM, 0.0, DirectionSet.N,
253 TERMINAL_OUT, ShutoffValveSymbol.DIM, 0.0, DirectionSet.S
256 public static ElementClass SHUTOFFVALVE_BUTTON_CLASS =
257 ElementClass.compile(
259 DefaultTransform.INSTANCE,
260 ShutoffValvePaint.INSTANCE,
262 BORDER_COLOR_HANDLER,
263 FixedSize.of(ShutoffValveSymbol.SHAPE.getBounds()),
264 StaticTerminals.compile(
265 TERMINAL_IN, -ShutoffValveSymbol.DIM, 0.0, DirectionSet.N,
266 TERMINAL_OUT, ShutoffValveSymbol.DIM, 0.0, DirectionSet.S
269 public static ElementClass SWITCH_CLASS =
270 ElementClass.compile(
271 DefaultTransform.INSTANCE,
272 SwitchPaint.INSTANCE,
273 BORDER_COLOR_HANDLER,
274 FixedSize.of(SwitchSymbol.BOUNDS),
275 StaticTerminals.compile(
276 TERMINAL_IN, SwitchSymbol.BOUNDS.getCenterX(), SwitchSymbol.BOUNDS.getMinY(), DirectionSet.N,
277 TERMINAL_OUT, SwitchSymbol.BOUNDS.getCenterX(), SwitchSymbol.BOUNDS.getMaxY(), DirectionSet.S
280 public static ElementClass SWITCH_BUTTON_CLASS =
281 ElementClass.compile(
283 DefaultTransform.INSTANCE,
284 SwitchPaint.INSTANCE,
285 BORDER_COLOR_HANDLER,
286 FixedSize.of(SwitchSymbol.BOUNDS),
287 StaticTerminals.compile(
288 TERMINAL_IN, SwitchSymbol.BOUNDS.getCenterX(), SwitchSymbol.BOUNDS.getMinY(), DirectionSet.N,
289 TERMINAL_OUT, SwitchSymbol.BOUNDS.getCenterX(), SwitchSymbol.BOUNDS.getMaxY(), DirectionSet.S
292 public static ElementClass TURBINE_CLASS =
293 ElementClass.compile(
294 DefaultTransform.INSTANCE,
295 TurbinePaint.INSTANCE,
297 BORDER_COLOR_HANDLER,
298 FixedSize.of(TurbineSymbol.SHAPE.getBounds()),
299 StaticTerminals.compile(
300 TERMINAL_IN, -TurbineSymbol.DIM, 0.0, DirectionSet.N,
301 TERMINAL_OUT, TurbineSymbol.DIM, 0.0, DirectionSet.S
304 public static ElementClass TURBINE_BUTTON_CLASS =
305 ElementClass.compile(
307 DefaultTransform.INSTANCE,
308 TurbinePaint.INSTANCE,
310 BORDER_COLOR_HANDLER,
311 FixedSize.of(TurbineSymbol.BOUNDS),
312 StaticTerminals.compile(
313 TERMINAL_IN, -TurbineSymbol.DIM, 0.0, DirectionSet.N,
314 TERMINAL_OUT, TurbineSymbol.DIM, 0.0, DirectionSet.S
317 public static ElementClass VOLTAGETRANSFORMER_CLASS =
318 ElementClass.compile(
319 DefaultTransform.INSTANCE,
320 VoltageTransformerPaint.INSTANCE,
321 ADDITIONAL_COLOR_HANDLER,
322 BORDER_COLOR_HANDLER,
323 FixedSize.of(VoltageTransformerSymbol.BOUNDS),
324 StaticTerminals.compile(
325 TERMINAL_IN, VoltageTransformerSymbol.BOUNDS.getCenterX(), VoltageTransformerSymbol.BOUNDS.getMinY(), DirectionSet.N,
326 TERMINAL_OUT, VoltageTransformerSymbol.BOUNDS.getCenterX(), VoltageTransformerSymbol.BOUNDS.getMaxY(), DirectionSet.S
329 public static ElementClass VOLTAGETRANSFORMER_BUTTON_CLASS =
330 ElementClass.compile(
332 DefaultTransform.INSTANCE,
333 VoltageTransformerPaint.INSTANCE,
334 ADDITIONAL_COLOR_HANDLER,
335 BORDER_COLOR_HANDLER,
336 FixedSize.of(VoltageTransformerSymbol.BOUNDS),
337 StaticTerminals.compile(
338 TERMINAL_IN, VoltageTransformerSymbol.BOUNDS.getCenterX(), VoltageTransformerSymbol.BOUNDS.getMinY(), DirectionSet.N,
339 TERMINAL_OUT, VoltageTransformerSymbol.BOUNDS.getCenterX(), VoltageTransformerSymbol.BOUNDS.getMaxY(), DirectionSet.S
342 public static ElementClass CHIMNEY_CLASS =
343 ElementClass.compile(
344 DefaultTransform.INSTANCE,
345 ChimneyPaint.INSTANCE,
347 BORDER_COLOR_HANDLER,
348 FixedSize.of(ChimneySymbol.BOUNDS)
350 public static ElementClass CHIMNEY_BUTTON_CLASS =
351 ElementClass.compile(
353 DefaultTransform.INSTANCE,
354 ChimneyPaint.INSTANCE,
356 BORDER_COLOR_HANDLER,
357 FixedSize.of(ChimneySymbol.BOUNDS)
359 public static ElementClass GENERATOR_CLASS =
360 ElementClass.compile(
361 DefaultTransform.INSTANCE,
362 GeneratorPaint.INSTANCE,
364 BORDER_COLOR_HANDLER,
365 FixedSize.of(GeneratorSymbol.BOUNDS),
366 StaticTerminals.compile(
367 TERMINAL_IN, -GeneratorSymbol.DIM, 0.0, DirectionSet.W,
368 TERMINAL_OUT, GeneratorSymbol.DIM, 0.0, DirectionSet.E
371 public static ElementClass GENERATOR_BUTTON_CLASS =
372 ElementClass.compile(
374 DefaultTransform.INSTANCE,
375 GeneratorPaint.INSTANCE,
377 BORDER_COLOR_HANDLER,
378 FixedSize.of(GeneratorSymbol.BOUNDS),
379 StaticTerminals.compile(
380 TERMINAL_IN, -GeneratorSymbol.DIM, 0.0, DirectionSet.W,
381 TERMINAL_OUT, GeneratorSymbol.DIM, 0.0, DirectionSet.E
384 public static ElementClass TANK_CLASS =
385 ElementClass.compile(
386 DefaultTransform.INSTANCE,
389 BORDER_COLOR_HANDLER,
390 Resizeable.initialSize(40, 15)
392 public static ElementClass TANK_BUTTON_CLASS =
393 ElementClass.compile(
395 DefaultTransform.INSTANCE,
398 BORDER_COLOR_HANDLER,
399 Resizeable.initialSize(40, 15)
401 public static ElementClass TANK2_CLASS =
402 ElementClass.compile(
403 DefaultTransform.INSTANCE,
406 BORDER_COLOR_HANDLER,
407 ADDITIONAL_COLOR_HANDLER,
408 Resizeable.initialSize(40, 15)
410 public static ElementClass TANK2_BUTTON_CLASS =
411 ElementClass.compile(
413 DefaultTransform.INSTANCE,
416 ADDITIONAL_COLOR_HANDLER,
417 BORDER_COLOR_HANDLER,
418 Resizeable.initialSize(40, 15)
423 public static class BoilerPaint implements SceneGraph {
425 private static final long serialVersionUID = -4545277680608759806L;
426 public static final BoilerPaint INSTANCE = new BoilerPaint();
428 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
431 public void cleanup(IElement e) {
432 Node node = e.removeHint(SG_NODE);
438 public void init(IElement e, G2DParentNode parent) {
439 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
441 node = parent.addNode(G2DParentNode.class);
442 e.setHint(SG_NODE, node);
444 AffineTransform at = ElementUtils.getTransform(e);
445 if(at != null) node.setTransform(at);
447 Color fc = ElementUtils.getFillColor(e);
448 Color bc = ElementUtils.getBorderColor(e);
449 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
453 ps = new BoilerSymbol2(fc, bc, OperationSymbols.BOILER_HES);
455 ps = OperationSymbols.BOILER_SHADOW;
457 // if (press==PressStatus.NORMAL)
458 // gc.getGraphics2D().translate(-2, -3);
466 public static class NoSpinPaint implements SceneGraph {
468 private static final long serialVersionUID = 801958319361745846L;
469 public static final NoSpinPaint INSTANCE = new NoSpinPaint();
471 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
474 public void cleanup(IElement e) {
475 Node node = e.removeHint(SG_NODE);
481 public void init(IElement e, G2DParentNode parent) {
482 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
484 node = parent.addNode(G2DParentNode.class);
485 e.setHint(SG_NODE, node);
487 AffineTransform at = ElementUtils.getTransform(e);
488 if(at != null) node.setTransform(at);
490 Color fc = ElementUtils.getFillColor(e);
491 Color bc = ElementUtils.getBorderColor(e);
492 if (bc==null) return;
493 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
497 ps = new NoSpinSymbol(fc, bc);
499 ps = OperationSymbols.NO_SPIN_SHADOW;
501 // if (press==PressStatus.NORMAL)
502 // gc.getGraphics2D().translate(-2, -3);
510 public static class ControlValvePaint implements SceneGraph {
512 private static final long serialVersionUID = -8208633777668762027L;
513 public static final ControlValvePaint INSTANCE = new ControlValvePaint();
514 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
517 public void cleanup(IElement e) {
518 Node node = e.removeHint(SG_NODE);
524 public void init(IElement e, G2DParentNode parent) {
525 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
527 node = parent.addNode(G2DParentNode.class);
528 e.setHint(SG_NODE, node);
530 AffineTransform at = ElementUtils.getTransform(e);
531 if(at != null) node.setTransform(at);
533 Color fc = ElementUtils.getFillColor(e);
534 Color bc = ElementUtils.getBorderColor(e);
535 if (bc==null) return;
536 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
540 ps = new ControlValveSymbol(fc, bc);
542 ps = OperationSymbols.CONTROLVALVE_SHADOW;
544 // if (press==PressStatus.NORMAL)
545 // gc.getGraphics2D().translate(-2, -3);
552 public static class ThreeWayValvePaint implements SceneGraph {
554 private static final long serialVersionUID = -1848763601182093048L;
555 public static final ThreeWayValvePaint INSTANCE = new ThreeWayValvePaint();
556 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
559 public void cleanup(IElement e) {
560 Node node = e.removeHint(SG_NODE);
566 public void init(IElement e, G2DParentNode parent) {
567 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
569 node = parent.addNode(G2DParentNode.class);
570 e.setHint(SG_NODE, node);
572 AffineTransform at = ElementUtils.getTransform(e);
573 if(at != null) node.setTransform(at);
575 Color fc = ElementUtils.getFillColor(e);
576 Color bc = ElementUtils.getBorderColor(e);
577 if (bc==null) return;
578 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
582 ps = new ThreeWayValveSymbol(fc, bc);
584 ps = OperationSymbols.THREEWAYVALVE_SHADOW;
586 // if (press==PressStatus.NORMAL)
587 // gc.getGraphics2D().translate(-2, -3);
594 public static class HeatExchangerPaint implements SceneGraph {
596 private static final long serialVersionUID = -5482316746105556083L;
597 public static final HeatExchangerPaint INSTANCE = new HeatExchangerPaint();
598 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
601 public void cleanup(IElement e) {
602 Node node = e.removeHint(SG_NODE);
608 public void init(IElement e, G2DParentNode parent) {
609 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
611 node = parent.addNode(G2DParentNode.class);
612 e.setHint(SG_NODE, node);
614 AffineTransform at = ElementUtils.getTransform(e);
615 if(at != null) node.setTransform(at);
617 Color fc = ElementUtils.getFillColor(e);
618 Color bc = ElementUtils.getBorderColor(e);
619 if (bc==null) return;
620 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
624 ps = new HeatExchangerSymbol(fc, bc);
626 ps = OperationSymbols.HEATEXCHANGER_SHADOW;
628 // if (press==PressStatus.NORMAL)
629 // gc.getGraphics2D().translate(-2, -3);
638 public static class PumpPaint implements SceneGraph {
640 private static final long serialVersionUID = 5899800511420262337L;
641 public static final PumpPaint INSTANCE = new PumpPaint();
642 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
645 public void cleanup(IElement e) {
646 Node node = e.removeHint(SG_NODE);
652 public void init(IElement e, G2DParentNode parent) {
653 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
655 node = parent.addNode(G2DParentNode.class);
656 e.setHint(SG_NODE, node);
658 AffineTransform at = ElementUtils.getTransform(e);
659 if(at != null) node.setTransform(at);
661 Color fc = ElementUtils.getFillColor(e);
662 Color bc = ElementUtils.getBorderColor(e);
663 if (bc==null) return;
664 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
668 ps = new PumpSymbol(fc, bc);
670 ps = OperationSymbols.PUMP_SHADOW;
672 // if (press==PressStatus.NORMAL)
673 // gc.getGraphics2D().translate(-2, -3);
681 public static class ShutoffValvePaint implements SceneGraph {
683 private static final long serialVersionUID = 6258753947743405959L;
684 public static final ShutoffValvePaint INSTANCE = new ShutoffValvePaint();
685 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
688 public void cleanup(IElement e) {
689 Node node = e.removeHint(SG_NODE);
695 public void init(IElement e, G2DParentNode parent) {
696 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
698 node = parent.addNode(G2DParentNode.class);
699 e.setHint(SG_NODE, node);
701 AffineTransform at = ElementUtils.getTransform(e);
702 if(at != null) node.setTransform(at);
704 Color fc = ElementUtils.getFillColor(e);
705 Color bc = ElementUtils.getBorderColor(e);
706 if (bc==null) return;
707 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
711 ps = new ShutoffValveSymbol(fc, bc);
713 ps = OperationSymbols.SHUTOFFVALVE_SHADOW;
715 // if (press==PressStatus.NORMAL)
716 // gc.getGraphics2D().translate(-2, -3);
725 public static class SwitchPaint implements SceneGraph {
727 private static final long serialVersionUID = -171980746141963729L;
728 public static final SwitchPaint INSTANCE = new SwitchPaint();
729 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
732 public void cleanup(IElement e) {
733 Node node = e.removeHint(SG_NODE);
739 public void init(IElement e, G2DParentNode parent) {
740 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
742 node = parent.addNode(G2DParentNode.class);
743 e.setHint(SG_NODE, node);
745 AffineTransform at = ElementUtils.getTransform(e);
746 if(at != null) node.setTransform(at);
748 Color bc = ElementUtils.getBorderColor(e);
749 if (bc==null) return;
750 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
754 ps = new SwitchSymbol(bc);
756 ps = OperationSymbols.SWITCH_SHADOW;
758 // if (press==PressStatus.NORMAL)
759 // gc.getGraphics2D().translate(-2, -3);
766 public static class TurbinePaint implements SceneGraph {
768 private static final long serialVersionUID = -920598007509848402L;
769 public static final TurbinePaint INSTANCE = new TurbinePaint();
770 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
773 public void cleanup(IElement e) {
774 Node node = e.removeHint(SG_NODE);
780 public void init(IElement e, G2DParentNode parent) {
781 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
783 node = parent.addNode(G2DParentNode.class);
784 e.setHint(SG_NODE, node);
787 AffineTransform at = ElementUtils.getTransform(e);
788 if(at != null) node.setTransform(at);
790 Color fc = ElementUtils.getFillColor(e);
791 Color bc = ElementUtils.getBorderColor(e);
792 if (bc==null) return;
793 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
797 ps = new TurbineSymbol(bc, fc);
799 ps = OperationSymbols.TURBINE_SHADOW;
801 // if (press==PressStatus.NORMAL)
802 // gc.getGraphics2D().translate(-2, -3);
808 public static class CompressorPaint implements SceneGraph {
810 private static final long serialVersionUID = 6961201125549409431L;
811 public static final CompressorPaint INSTANCE = new CompressorPaint();
812 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
815 public void cleanup(IElement e) {
816 Node node = e.removeHint(SG_NODE);
822 public void init(IElement e, G2DParentNode parent) {
823 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
825 node = parent.addNode(G2DParentNode.class);
826 e.setHint(SG_NODE, node);
829 AffineTransform at = ElementUtils.getTransform(e);
830 if(at != null) node.setTransform(at);
832 Color fc = ElementUtils.getFillColor(e);
833 Color bc = ElementUtils.getBorderColor(e);
834 if (bc==null) return;
835 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
839 ps = new CompressorSymbol(bc, fc);
841 ps = OperationSymbols.COMPRESSOR_SHADOW;
843 // if (press==PressStatus.NORMAL)
844 // gc.getGraphics2D().translate(-2, -3);
850 public static class VoltageTransformerPaint implements SceneGraph {
852 private static final long serialVersionUID = -4935588203299292629L;
853 public static final VoltageTransformerPaint INSTANCE = new VoltageTransformerPaint();
854 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
857 public void cleanup(IElement e) {
858 Node node = e.removeHint(SG_NODE);
864 public void init(IElement e, G2DParentNode parent) {
865 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
867 node = parent.addNode(G2DParentNode.class);
868 e.setHint(SG_NODE, node);
870 AffineTransform at = ElementUtils.getTransform(e);
871 if(at != null) node.setTransform(at);
873 Color color1 = ElementUtils.getBorderColor(e);
874 Color color2 = ElementUtils.getAdditionalColor(e);
875 if (color1==null || color2==null) return;
876 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
880 ps = new VoltageTransformerSymbol(color1, color2);
882 ps = OperationSymbols.VOLTAGETRANSFORMER_SHADOW;
884 // if (press==PressStatus.NORMAL)
885 // gc.getGraphics2D().translate(-2, -3);
891 public static class ChimneyPaint implements SceneGraph {
893 private static final long serialVersionUID = 1001249555587430505L;
894 public static final ChimneyPaint INSTANCE = new ChimneyPaint();
895 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
898 public void cleanup(IElement e) {
899 Node node = e.removeHint(SG_NODE);
905 public void init(IElement e, G2DParentNode parent) {
906 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
908 node = parent.addNode(G2DParentNode.class);
909 e.setHint(SG_NODE, node);
911 AffineTransform at = ElementUtils.getTransform(e);
912 if(at != null) node.setTransform(at);
914 Color fc = ElementUtils.getFillColor(e);
915 Color bc = ElementUtils.getBorderColor(e);
916 if (bc==null) return;
917 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
921 ps = new ChimneySymbol(fc, bc);
923 ps = OperationSymbols.CHIMNEY_SHADOW;
925 // if (press==PressStatus.NORMAL)
926 // gc.getGraphics2D().translate(-2, -3);
932 public static class GeneratorPaint implements SceneGraph {
934 private static final long serialVersionUID = -1080419588160841727L;
935 public static final GeneratorPaint INSTANCE = new GeneratorPaint();
936 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
939 public void cleanup(IElement e) {
940 Node node = e.removeHint(SG_NODE);
946 public void init(IElement e, G2DParentNode parent) {
947 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
949 node = parent.addNode(G2DParentNode.class);
950 e.setHint(SG_NODE, node);
952 AffineTransform at = ElementUtils.getTransform(e);
953 if(at != null) node.setTransform(at);
955 Color fc = ElementUtils.getFillColor(e);
956 Color bc = ElementUtils.getBorderColor(e);
957 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
961 ps = new GeneratorSymbol(fc, bc);
963 ps = OperationSymbols.GENERATOR_SHADOW;
965 // if (press==PressStatus.NORMAL)
966 // gc.getGraphics2D().translate(-2, -3);
972 public static class TankPaint implements SceneGraph {
974 private static final long serialVersionUID = -461979630655554477L;
975 public static final TankPaint INSTANCE = new TankPaint();
976 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
979 public void cleanup(IElement e) {
980 Node node = e.removeHint(SG_NODE);
986 public void init(IElement e, G2DParentNode parent) {
987 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
989 node = parent.addNode(G2DParentNode.class);
990 e.setHint(SG_NODE, node);
992 AffineTransform at = ElementUtils.getTransform(e);
993 if(at != null) node.setTransform(at);
995 Color fc = ElementUtils.getFillColor(e);
996 Color bc = ElementUtils.getBorderColor(e);
997 Rectangle2D bounds = ElementUtils.getElementBounds(e);
998 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
1002 ps = new TankSymbol(bounds, 5.0, bc, fc);
1004 ps = OperationSymbols.TANK_SHADOW;
1006 // if (press==PressStatus.NORMAL)
1007 // gc.getGraphics2D().translate(-2, -3);
1013 public static class Tank2Paint implements SceneGraph {
1015 private static final long serialVersionUID = 5232349098800595743L;
1016 public static final Tank2Paint INSTANCE = new Tank2Paint();
1017 public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
1020 public void cleanup(IElement e) {
1021 Node node = e.removeHint(SG_NODE);
1027 public void init(IElement e, G2DParentNode parent) {
1028 G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
1030 node = parent.addNode(G2DParentNode.class);
1031 e.setHint(SG_NODE, node);
1033 AffineTransform at = ElementUtils.getTransform(e);
1034 if(at != null) node.setTransform(at);
1036 Color fc = ElementUtils.getFillColor(e);
1037 Color bc = ElementUtils.getBorderColor(e);
1038 Color ac = ElementUtils.getAdditionalColor(e);
1039 Rectangle2D bounds = ElementUtils.getElementBounds(e);
1040 PressStatus press = null;//ElementUtils.getPressStatus(e, ctx); // FIXME: scenegraph does not support context
1044 ps = new Tank2Symbol(bounds, 5.0, bc, fc, ac);
1046 ps = OperationSymbols.TANK2_SHADOW;
1048 // if (press==PressStatus.NORMAL)
1049 // gc.getGraphics2D().translate(-2, -3);