MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / append

Method append

src/org/jibble/epsgraphics/EpsDocument.java:90–134  ·  view source on GitHub ↗

Appends a line to the EpsDocument. A new line character is added to the end of the line when it is added.

(EpsGraphics2D g, String line)

Source from the content-addressed store, hash-verified

88 * to the end of the line when it is added.
89 */
90 public synchronized void append(EpsGraphics2D g, String line) {
91 if(_lastG==null) {
92 _lastG = g;
93 } else if(g!=_lastG) {
94 EpsGraphics2D lastG = _lastG;
95 _lastG = g;
96 // We are being drawn on with a different EpsGraphics2D context.
97 // We may need to update the clip, etc from this new context.
98 if(g.getClip()!=lastG.getClip()) {
99 g.setClip(g.getClip());
100 }
101 if(!g.getColor().equals(lastG.getColor())) {
102 g.setColor(g.getColor());
103 }
104 if(!g.getBackground().equals(lastG.getBackground())) {
105 g.setBackground(g.getBackground());
106 }
107 // We don't need this, as this only affects the stroke and font,
108 // which are dealt with separately later on.
109 // if (!g.getTransform().equals(lastG.getTransform())) {
110 // g.setTransform(g.getTransform());
111 // }
112 if(!g.getPaint().equals(lastG.getPaint())) {
113 g.setPaint(g.getPaint());
114 }
115 if(!g.getComposite().equals(lastG.getComposite())) {
116 g.setComposite(g.getComposite());
117 }
118 if(!g.getComposite().equals(lastG.getComposite())) {
119 g.setComposite(g.getComposite());
120 }
121 if(!g.getFont().equals(lastG.getFont())) {
122 g.setFont(g.getFont());
123 }
124 if(!g.getStroke().equals(lastG.getStroke())) {
125 g.setStroke(g.getStroke());
126 }
127 }
128 _lastG = g;
129 try {
130 _bufferedWriter.write(line+"\n"); //$NON-NLS-1$
131 } catch(IOException e) {
132 throw new EpsException("Could not write to the output file: "+e); //$NON-NLS-1$
133 }
134 }
135
136 /**
137 * Outputs the contents of the EPS document to the specified

Callers

nothing calls this directly

Calls 15

getClipMethod · 0.95
getColorMethod · 0.95
getBackgroundMethod · 0.95
getPaintMethod · 0.95
getCompositeMethod · 0.95
getFontMethod · 0.95
getStrokeMethod · 0.95
setClipMethod · 0.80
setPaintMethod · 0.80
setCompositeMethod · 0.80
equalsMethod · 0.65
getFontMethod · 0.65

Tested by

no test coverage detected