]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/operationsymbols/OperationClasses.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / elementclass / operationsymbols / OperationClasses.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.elementclass.operationsymbols;
13
14 import java.awt.Color;
15 import java.awt.geom.AffineTransform;
16 import java.awt.geom.Rectangle2D;
17
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;
58
59 /**
60  * Operation symbol handlers.
61  * 
62  * @author Toni Kalajainen
63  */
64 public class OperationClasses {
65     
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);
69         
70         public static final Terminal TERMINAL_IN = new TerminalImpl(); 
71         public static final Terminal TERMINAL_OUT = new TerminalImpl(); 
72         
73         public static ElementClass BOILER_CLASS =
74                 ElementClass.compile(
75                                 DefaultTransform.INSTANCE,
76                                 BoilerPaint.INSTANCE,
77                                 FILL_COLOR_HANDLER,
78                                 BORDER_COLOR_HANDLER,
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
83                                                 )
84                                 );
85         public static ElementClass BOILER_BUTTON_CLASS =
86                 ElementClass.compile(
87                                 Clickable.INSTANCE,
88                                 DefaultTransform.INSTANCE,
89                                 BoilerPaint.INSTANCE,
90                                 FILL_COLOR_HANDLER,
91                                 BORDER_COLOR_HANDLER,
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
96                                                 )
97                                 );
98         public static ElementClass NO_SPIN_CLASS =
99                 ElementClass.compile(
100                                 DefaultTransform.INSTANCE,
101                                 NoSpinPaint.INSTANCE,
102                                 FILL_COLOR_HANDLER,
103                                 BORDER_COLOR_HANDLER,
104                                 FixedSize.of(NoSpinSymbol.BOUNDS),
105                                 StaticTerminals.compile(
106                                                 TERMINAL_IN,    0.0, 0.0, DirectionSet.NESW
107                                                 )                               
108                                 );
109         public static ElementClass NO_SPIN_BUTTON_CLASS =
110                 ElementClass.compile(
111                                 Clickable.INSTANCE,
112                                 DefaultTransform.INSTANCE,
113                                 NoSpinPaint.INSTANCE,
114                                 FILL_COLOR_HANDLER,
115                                 BORDER_COLOR_HANDLER,
116                                 FixedSize.of(NoSpinSymbol.BOUNDS),
117                                 StaticTerminals.compile(
118                                                 TERMINAL_IN,    0.0, 0.0, DirectionSet.NESW
119                                                 )                               
120                                 );                      
121         public static ElementClass COMPRESSOR_CLASS =
122                 ElementClass.compile(
123                                 DefaultTransform.INSTANCE,
124                                 CompressorPaint.INSTANCE,
125                                 FILL_COLOR_HANDLER,
126                                 BORDER_COLOR_HANDLER,
127                                 FixedSize.of(CompressorSymbol.BOUNDS),
128                                 StaticTerminals.compile(
129                                                 TERMINAL_IN,    0.0, 0.0, DirectionSet.NESW
130                                                 )                               
131                                 );
132         public static ElementClass COMPRESSOR_BUTTON_CLASS =
133                 ElementClass.compile(
134                                 Clickable.INSTANCE,
135                                 DefaultTransform.INSTANCE,
136                                 CompressorPaint.INSTANCE,
137                                 FILL_COLOR_HANDLER,
138                                 BORDER_COLOR_HANDLER,
139                                 FixedSize.of(CompressorSymbol.BOUNDS),
140                                 StaticTerminals.compile(
141                                                 TERMINAL_IN,    0.0, 0.0, DirectionSet.NESW
142                                                 )                               
143                                 );              
144         public static ElementClass CONTROLVALVE_CLASS =
145                 ElementClass.compile(
146                                 DefaultTransform.INSTANCE,
147                                 ControlValvePaint.INSTANCE,
148                                 FILL_COLOR_HANDLER,
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
154                                                 )                               
155                                 );      
156         public static ElementClass CONTROLVALVE_BUTTON_CLASS =
157                 ElementClass.compile(
158                                 Clickable.INSTANCE,
159                                 DefaultTransform.INSTANCE,
160                                 ControlValvePaint.INSTANCE,
161                                 FILL_COLOR_HANDLER,
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
167                                                 )                               
168                                 );              
169         public static ElementClass THREEWAYVALVE_CLASS =
170                 ElementClass.compile(
171                                 DefaultTransform.INSTANCE,
172                                 ThreeWayValvePaint.INSTANCE,
173                                 FILL_COLOR_HANDLER,
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
179                                                 )                               
180                                 );      
181         public static ElementClass THREEWAYVALVE_BUTTON_CLASS =
182                 ElementClass.compile(
183                                 Clickable.INSTANCE,
184                                 DefaultTransform.INSTANCE,
185                                 ThreeWayValvePaint.INSTANCE,
186                                 FILL_COLOR_HANDLER,
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
192                                                 )                               
193                                 );              
194         public static ElementClass HEATEXCHANGER_CLASS =
195                 ElementClass.compile(
196                                 DefaultTransform.INSTANCE,
197                                 HeatExchangerPaint.INSTANCE,
198                                 FILL_COLOR_HANDLER,
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
204                                                 )                                                               
205                                 );      
206         public static ElementClass HEATEXCHANGER_BUTTON_CLASS =
207                 ElementClass.compile(
208                                 Clickable.INSTANCE,
209                                 DefaultTransform.INSTANCE,
210                                 HeatExchangerPaint.INSTANCE,
211                                 FILL_COLOR_HANDLER,
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                                             
217                                                 )                                                               
218                                 );              
219         public static ElementClass PUMP_CLASS =
220                 ElementClass.compile(
221                                 DefaultTransform.INSTANCE,
222                                 PumpPaint.INSTANCE,
223                                 FILL_COLOR_HANDLER,
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
229                                                 )                                       
230                                 );
231         public static ElementClass PUMP_BUTTON_CLASS =
232                 ElementClass.compile(
233                                 Clickable.INSTANCE,
234                                 DefaultTransform.INSTANCE,
235                                 PumpPaint.INSTANCE,
236                                 FILL_COLOR_HANDLER,
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
242                                                 )                                       
243                                 );      
244         public static ElementClass SHUTOFFVALVE_CLASS =
245                 ElementClass.compile(
246                                 DefaultTransform.INSTANCE,
247                                 ShutoffValvePaint.INSTANCE,
248                                 FILL_COLOR_HANDLER,
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
254                                                 )                                       
255                                 );      
256         public static ElementClass SHUTOFFVALVE_BUTTON_CLASS =
257                 ElementClass.compile(
258                                 Clickable.INSTANCE,
259                                 DefaultTransform.INSTANCE,
260                                 ShutoffValvePaint.INSTANCE,
261                                 FILL_COLOR_HANDLER,
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
267                                                 )                                       
268                                 );              
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                                         
278                                                 )                                       
279                                 );      
280         public static ElementClass SWITCH_BUTTON_CLASS =
281                 ElementClass.compile(
282                                 Clickable.INSTANCE,
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                                         
290                                                 )                                       
291                                 );              
292         public static ElementClass TURBINE_CLASS =
293                 ElementClass.compile(
294                                 DefaultTransform.INSTANCE,
295                                 TurbinePaint.INSTANCE,
296                                 FILL_COLOR_HANDLER,
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
302                                                 )                                               
303                                 );              
304         public static ElementClass TURBINE_BUTTON_CLASS =
305                 ElementClass.compile(
306                                 Clickable.INSTANCE,
307                                 DefaultTransform.INSTANCE,
308                                 TurbinePaint.INSTANCE,
309                                 FILL_COLOR_HANDLER,
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
315                                                 )                                               
316                                 );              
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
327                                                 )                                                       
328                                 );
329         public static ElementClass VOLTAGETRANSFORMER_BUTTON_CLASS =
330                 ElementClass.compile(
331                                 Clickable.INSTANCE,
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
340                                                 )                                                       
341                                 );      
342         public static ElementClass CHIMNEY_CLASS =
343                 ElementClass.compile(
344                                 DefaultTransform.INSTANCE,
345                                 ChimneyPaint.INSTANCE,
346                                 FILL_COLOR_HANDLER,
347                                 BORDER_COLOR_HANDLER,
348                                 FixedSize.of(ChimneySymbol.BOUNDS)
349                                 );              
350         public static ElementClass CHIMNEY_BUTTON_CLASS =
351                 ElementClass.compile(
352                                 Clickable.INSTANCE,
353                                 DefaultTransform.INSTANCE,
354                                 ChimneyPaint.INSTANCE,
355                                 FILL_COLOR_HANDLER,
356                                 BORDER_COLOR_HANDLER,
357                                 FixedSize.of(ChimneySymbol.BOUNDS)
358                                 );              
359         public static ElementClass GENERATOR_CLASS =
360                 ElementClass.compile(
361                                 DefaultTransform.INSTANCE,
362                                 GeneratorPaint.INSTANCE,
363                                 FILL_COLOR_HANDLER,
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
369                                                 )                                                               
370                                 );              
371         public static ElementClass GENERATOR_BUTTON_CLASS =
372                 ElementClass.compile(
373                                 Clickable.INSTANCE,
374                                 DefaultTransform.INSTANCE,
375                                 GeneratorPaint.INSTANCE,
376                                 FILL_COLOR_HANDLER,
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
382                                                 )                                                                                               
383                                 );
384         public static ElementClass TANK_CLASS =
385                 ElementClass.compile(
386                                 DefaultTransform.INSTANCE,
387                                 TankPaint.INSTANCE,
388                                 FILL_COLOR_HANDLER,
389                                 BORDER_COLOR_HANDLER,
390                                 Resizeable.initialSize(40, 15)
391                                 );              
392         public static ElementClass TANK_BUTTON_CLASS =
393                 ElementClass.compile(
394                                 Clickable.INSTANCE,
395                                 DefaultTransform.INSTANCE,
396                                 TankPaint.INSTANCE,
397                                 FILL_COLOR_HANDLER,
398                                 BORDER_COLOR_HANDLER,
399                                 Resizeable.initialSize(40, 15)
400                                 );              
401         public static ElementClass TANK2_CLASS =
402                 ElementClass.compile(
403                                 DefaultTransform.INSTANCE,
404                                 Tank2Paint.INSTANCE,
405                                 FILL_COLOR_HANDLER,
406                                 BORDER_COLOR_HANDLER,
407                                 ADDITIONAL_COLOR_HANDLER,                               
408                                 Resizeable.initialSize(40, 15)
409                                 );              
410         public static ElementClass TANK2_BUTTON_CLASS =
411                 ElementClass.compile(
412                                 Clickable.INSTANCE,
413                                 DefaultTransform.INSTANCE,
414                                 Tank2Paint.INSTANCE,
415                                 FILL_COLOR_HANDLER,
416                                 ADDITIONAL_COLOR_HANDLER,                               
417                                 BORDER_COLOR_HANDLER,
418                                 Resizeable.initialSize(40, 15)
419                                 );              
420         
421         
422         
423         public static class BoilerPaint implements SceneGraph {         
424
425                 private static final long serialVersionUID = -4545277680608759806L;
426                 public static final BoilerPaint INSTANCE = new BoilerPaint();
427                 
428             public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
429
430                 @Override
431                 public void cleanup(IElement e) {
432                Node node = e.removeHint(SG_NODE);
433                if (node != null)
434                    node.remove();
435                 }
436
437                 @Override
438                 public void init(IElement e, G2DParentNode parent) {
439                G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
440                if (node == null) {
441                    node = parent.addNode(G2DParentNode.class);
442                    e.setHint(SG_NODE, node);
443                }
444                         AffineTransform at      = ElementUtils.getTransform(e);
445                         if(at != null) node.setTransform(at);
446
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
450                         Image ps                = null;
451                         
452                         if (press==null) {
453                                 ps = new BoilerSymbol2(fc, bc, OperationSymbols.BOILER_HES);
454                         } else {
455                                 ps = OperationSymbols.BOILER_SHADOW;
456 // ?????????                            
457 //                              if (press==PressStatus.NORMAL) 
458 //                                      gc.getGraphics2D().translate(-2, -3);
459                         }
460                         
461                         ps.init(node);
462                 }
463         }
464         
465         
466         public static class NoSpinPaint implements SceneGraph {
467
468                 private static final long serialVersionUID = 801958319361745846L;
469                 public static final NoSpinPaint INSTANCE = new NoSpinPaint();
470                 
471             public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
472
473                 @Override
474                 public void cleanup(IElement e) {
475                Node node = e.removeHint(SG_NODE);
476                if (node != null)
477                    node.remove();
478                 }
479
480                 @Override
481                 public void init(IElement e, G2DParentNode parent) {
482                G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
483                if (node == null) {
484                    node = parent.addNode(G2DParentNode.class);
485                    e.setHint(SG_NODE, node);
486                }
487                         AffineTransform at      = ElementUtils.getTransform(e);
488                         if(at != null) node.setTransform(at);
489
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
494                         Image ps                = null;
495                         
496                         if (press==null) {
497                                 ps = new NoSpinSymbol(fc, bc);
498                         } else {
499                                 ps = OperationSymbols.NO_SPIN_SHADOW;
500 // ?????????                            
501 //                              if (press==PressStatus.NORMAL)
502 //                                      gc.getGraphics2D().translate(-2, -3);
503                         }
504                         
505                         ps.init(node);
506                 }
507         }
508
509         
510         public static class ControlValvePaint implements SceneGraph {
511
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");
515
516                 @Override
517                 public void cleanup(IElement e) {
518                Node node = e.removeHint(SG_NODE);
519                if (node != null)
520                    node.remove();
521                 }
522
523                 @Override
524                 public void init(IElement e, G2DParentNode parent) {
525                G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
526                if (node == null) {
527                    node = parent.addNode(G2DParentNode.class);
528                    e.setHint(SG_NODE, node);
529                }
530                         AffineTransform at      = ElementUtils.getTransform(e);
531                         if(at != null) node.setTransform(at);
532
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
537                         Image ps                = null;
538                         
539                         if (press==null) {
540                                 ps = new ControlValveSymbol(fc, bc);
541                         } else {
542                                 ps = OperationSymbols.CONTROLVALVE_SHADOW;
543 // ?????????                            
544 //                              if (press==PressStatus.NORMAL)
545 //                                      gc.getGraphics2D().translate(-2, -3);
546                         }
547                         
548                         ps.init(node);
549                 }
550         }       
551         
552         public static class ThreeWayValvePaint implements SceneGraph {
553
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");
557
558                 @Override
559                 public void cleanup(IElement e) {
560                Node node = e.removeHint(SG_NODE);
561                if (node != null)
562                    node.remove();
563                 }
564
565                 @Override
566                 public void init(IElement e, G2DParentNode parent) {
567                G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
568                if (node == null) {
569                    node = parent.addNode(G2DParentNode.class);
570                    e.setHint(SG_NODE, node);
571                }
572                         AffineTransform at      = ElementUtils.getTransform(e);
573                         if(at != null) node.setTransform(at);
574
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
579                         Image ps                = null;
580                         
581                         if (press==null) {
582                                 ps = new ThreeWayValveSymbol(fc, bc);
583                         } else {
584                                 ps = OperationSymbols.THREEWAYVALVE_SHADOW;
585 // ?????????                            
586 //                              if (press==PressStatus.NORMAL)
587 //                                      gc.getGraphics2D().translate(-2, -3);
588                         }
589                         
590                         ps.init(node);
591                 }
592         }       
593         
594         public static class HeatExchangerPaint implements SceneGraph {
595
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");
599
600                 @Override
601                 public void cleanup(IElement e) {
602                Node node = e.removeHint(SG_NODE);
603                if (node != null)
604                    node.remove();
605                 }
606
607                 @Override
608                 public void init(IElement e, G2DParentNode parent) {
609                G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
610                if (node == null) {
611                    node = parent.addNode(G2DParentNode.class);
612                    e.setHint(SG_NODE, node);
613                }
614                         AffineTransform at      = ElementUtils.getTransform(e);
615                         if(at != null) node.setTransform(at);
616
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
621                         Image ps                = null;
622                         
623                         if (press==null) {
624                                 ps = new HeatExchangerSymbol(fc, bc);
625                         } else {
626                                 ps = OperationSymbols.HEATEXCHANGER_SHADOW;
627 // ?????????                            
628 //                              if (press==PressStatus.NORMAL)
629 //                                      gc.getGraphics2D().translate(-2, -3);
630                         }
631                         
632                         ps.init(node);
633                 }
634         }       
635                 
636         
637         
638         public static class PumpPaint implements SceneGraph {
639
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");
643
644                 @Override
645                 public void cleanup(IElement e) {
646                Node node = e.removeHint(SG_NODE);
647                if (node != null)
648                    node.remove();
649                 }
650
651                 @Override
652                 public void init(IElement e, G2DParentNode parent) {
653                G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
654                if (node == null) {
655                    node = parent.addNode(G2DParentNode.class);
656                    e.setHint(SG_NODE, node);
657                }
658                         AffineTransform at      = ElementUtils.getTransform(e);
659                         if(at != null) node.setTransform(at);
660
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
665                         Image ps                = null;
666                         
667                         if (press==null) {
668                                 ps = new PumpSymbol(fc, bc);
669                         } else {
670                                 ps = OperationSymbols.PUMP_SHADOW;
671 // ?????????                            
672 //                              if (press==PressStatus.NORMAL)
673 //                                      gc.getGraphics2D().translate(-2, -3);
674                         }
675                         
676                         ps.init(node);
677                 }
678         }       
679         
680         
681         public static class ShutoffValvePaint implements SceneGraph {
682
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");
686
687                 @Override
688                 public void cleanup(IElement e) {
689                Node node = e.removeHint(SG_NODE);
690                if (node != null)
691                    node.remove();
692                 }
693
694                 @Override
695                 public void init(IElement e, G2DParentNode parent) {
696                G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
697                if (node == null) {
698                    node = parent.addNode(G2DParentNode.class);
699                    e.setHint(SG_NODE, node);
700                }
701                         AffineTransform at      = ElementUtils.getTransform(e);
702                         if(at != null) node.setTransform(at);
703
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
708                         Image ps                = null;
709                         
710                         if (press==null) {
711                                 ps = new ShutoffValveSymbol(fc, bc);
712                         } else {
713                                 ps = OperationSymbols.SHUTOFFVALVE_SHADOW;
714 // ?????????                            
715 //                              if (press==PressStatus.NORMAL)
716 //                                      gc.getGraphics2D().translate(-2, -3);
717                         }
718                         
719                         ps.init(node);
720                 }
721         }       
722         
723         
724         
725         public static class SwitchPaint implements SceneGraph {
726
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");
730
731                 @Override
732                 public void cleanup(IElement e) {
733                Node node = e.removeHint(SG_NODE);
734                if (node != null)
735                    node.remove();
736                 }
737
738                 @Override
739                 public void init(IElement e, G2DParentNode parent) {
740                         G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
741                         if (node == null) {
742                                 node = parent.addNode(G2DParentNode.class);
743                                 e.setHint(SG_NODE, node);
744                         }
745                         AffineTransform at      = ElementUtils.getTransform(e);
746                         if(at != null) node.setTransform(at);
747
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
751                         Image ps                = null;
752                         
753                         if (press==null) {
754                                 ps = new SwitchSymbol(bc);
755                         } else {
756                                 ps = OperationSymbols.SWITCH_SHADOW;
757 // ?????????                            
758 //                              if (press==PressStatus.NORMAL)
759 //                                      gc.getGraphics2D().translate(-2, -3);
760                         }
761                         ps.init(node);
762                 }
763         }               
764
765         
766         public static class TurbinePaint implements SceneGraph {
767
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");
771
772                 @Override
773                 public void cleanup(IElement e) {
774                Node node = e.removeHint(SG_NODE);
775                if (node != null)
776                    node.remove();
777                 }
778
779                 @Override
780                 public void init(IElement e, G2DParentNode parent) {
781                         G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
782                         if (node == null) {
783                                 node = parent.addNode(G2DParentNode.class);
784                                 e.setHint(SG_NODE, node);
785                         }
786                         
787                         AffineTransform at      = ElementUtils.getTransform(e);
788                         if(at != null) node.setTransform(at);
789
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
794                         Image ps                = null;
795                         
796                         if (press==null) {
797                                 ps = new TurbineSymbol(bc, fc);
798                         } else {
799                                 ps = OperationSymbols.TURBINE_SHADOW;
800 // ?????????                            
801 //                              if (press==PressStatus.NORMAL)
802 //                                      gc.getGraphics2D().translate(-2, -3);
803                         }
804                         ps.init(node);
805                 }
806         }               
807
808         public static class CompressorPaint implements SceneGraph {
809
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");
813
814                 @Override
815                 public void cleanup(IElement e) {
816                Node node = e.removeHint(SG_NODE);
817                if (node != null)
818                    node.remove();
819                 }
820
821                 @Override
822                 public void init(IElement e, G2DParentNode parent) {
823                         G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
824                         if (node == null) {
825                                 node = parent.addNode(G2DParentNode.class);
826                                 e.setHint(SG_NODE, node);
827                         }
828                         
829                         AffineTransform at      = ElementUtils.getTransform(e);
830                         if(at != null) node.setTransform(at);
831
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
836                         Image ps                = null;
837                         
838                         if (press==null) {
839                                 ps = new CompressorSymbol(bc, fc);
840                         } else {
841                                 ps = OperationSymbols.COMPRESSOR_SHADOW;
842 // ?????????                            
843 //                              if (press==PressStatus.NORMAL)
844 //                                      gc.getGraphics2D().translate(-2, -3);
845                         }
846                         ps.init(node);
847                 }
848         }       
849         
850         public static class VoltageTransformerPaint implements SceneGraph {
851
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");
855
856                 @Override
857                 public void cleanup(IElement e) {
858                Node node = e.removeHint(SG_NODE);
859                if (node != null)
860                    node.remove();
861                 }
862
863                 @Override
864                 public void init(IElement e, G2DParentNode parent) {
865                         G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
866                         if (node == null) {
867                                 node = parent.addNode(G2DParentNode.class);
868                                 e.setHint(SG_NODE, node);
869                         }
870                         AffineTransform at      = ElementUtils.getTransform(e);
871                         if(at != null) node.setTransform(at);
872
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
877                         Image ps                = null;
878                         
879                         if (press==null) {
880                                 ps = new VoltageTransformerSymbol(color1, color2);
881                         } else {
882                                 ps = OperationSymbols.VOLTAGETRANSFORMER_SHADOW;
883 // ?????????                            
884 //                              if (press==PressStatus.NORMAL)
885 //                                      gc.getGraphics2D().translate(-2, -3);
886                         }
887                         ps.init(node);
888                 }
889         }               
890         
891         public static class ChimneyPaint implements SceneGraph {
892
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");
896
897                 @Override
898                 public void cleanup(IElement e) {
899                Node node = e.removeHint(SG_NODE);
900                if (node != null)
901                    node.remove();
902                 }
903
904                 @Override
905                 public void init(IElement e, G2DParentNode parent) {
906                         G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
907                         if (node == null) {
908                                 node = parent.addNode(G2DParentNode.class);
909                                 e.setHint(SG_NODE, node);
910                         }
911                         AffineTransform at      = ElementUtils.getTransform(e);
912                         if(at != null) node.setTransform(at);
913
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
918                         Image ps                = null;
919                         
920                         if (press==null) {
921                                 ps = new ChimneySymbol(fc, bc);
922                         } else {
923                                 ps = OperationSymbols.CHIMNEY_SHADOW;
924 // ?????????                            
925 //                              if (press==PressStatus.NORMAL)
926 //                                      gc.getGraphics2D().translate(-2, -3);
927                         }
928                         ps.init(node);
929                 }
930         }               
931         
932         public static class GeneratorPaint implements SceneGraph {
933
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");
937
938                 @Override
939                 public void cleanup(IElement e) {
940                Node node = e.removeHint(SG_NODE);
941                if (node != null)
942                    node.remove();
943                 }
944
945                 @Override
946                 public void init(IElement e, G2DParentNode parent) {
947                         G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
948                         if (node == null) {
949                                 node = parent.addNode(G2DParentNode.class);
950                                 e.setHint(SG_NODE, node);
951                         }
952                         AffineTransform at      = ElementUtils.getTransform(e);
953                         if(at != null) node.setTransform(at);
954
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
958                         Image ps                = null;
959                         
960                         if (press==null) {
961                                 ps = new GeneratorSymbol(fc, bc);
962                         } else {
963                                 ps = OperationSymbols.GENERATOR_SHADOW;
964 // ?????????                            
965 //                              if (press==PressStatus.NORMAL)
966 //                                      gc.getGraphics2D().translate(-2, -3);
967                         }
968                         ps.init(node);
969                 }
970         }               
971         
972         public static class TankPaint implements SceneGraph {
973
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");
977
978                 @Override
979                 public void cleanup(IElement e) {
980                Node node = e.removeHint(SG_NODE);
981                if (node != null)
982                    node.remove();
983                 }
984
985                 @Override
986                 public void init(IElement e, G2DParentNode parent) {
987                         G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
988                         if (node == null) {
989                                 node = parent.addNode(G2DParentNode.class);
990                                 e.setHint(SG_NODE, node);
991                         }
992                         AffineTransform at      = ElementUtils.getTransform(e);
993                         if(at != null) node.setTransform(at);
994
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
999                         Image ps                = null;
1000                         
1001                         if (press==null) {
1002                                 ps = new TankSymbol(bounds, 5.0, bc, fc);
1003                         } else {
1004                                 ps = OperationSymbols.TANK_SHADOW;
1005 // ?????????                            
1006 //                              if (press==PressStatus.NORMAL)
1007 //                                      gc.getGraphics2D().translate(-2, -3);
1008                         }
1009                         ps.init(node);
1010                 }
1011         }
1012         
1013         public static class Tank2Paint implements SceneGraph {
1014
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");
1018
1019                 @Override
1020                 public void cleanup(IElement e) {
1021                Node node = e.removeHint(SG_NODE);
1022                if (node != null)
1023                    node.remove();
1024                 }
1025
1026                 @Override
1027                 public void init(IElement e, G2DParentNode parent) {
1028                         G2DParentNode node = (G2DParentNode) e.getHint(SG_NODE);
1029                         if (node == null) {
1030                                 node = parent.addNode(G2DParentNode.class);
1031                                 e.setHint(SG_NODE, node);
1032                         }
1033                         AffineTransform at      = ElementUtils.getTransform(e);
1034                         if(at != null) node.setTransform(at);
1035
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
1041                         Image ps                = null;
1042                         
1043                         if (press==null) {
1044                                 ps = new Tank2Symbol(bounds, 5.0, bc, fc, ac);
1045                         } else {
1046                                 ps = OperationSymbols.TANK2_SHADOW;
1047 // ?????????                            
1048 //                              if (press==PressStatus.NORMAL)
1049 //                                      gc.getGraphics2D().translate(-2, -3);
1050                         }
1051                         ps.init(node);
1052                 }
1053         }       
1054         
1055 }