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

Method setColor

src/org/jibble/epsgraphics/EpsGraphics2D.java:856–874  ·  view source on GitHub ↗

Sets the Color to be used when drawing all future shapes, text, etc.

(Color c)

Source from the content-addressed store, hash-verified

854 * Sets the Color to be used when drawing all future shapes, text, etc.
855 */
856 @Override
857public void setColor(Color c) {
858 if(c==null) {
859 c = Color.black;
860 }
861 _color = c;
862 if(getColorDepth()==BLACK_AND_WHITE) {
863 float value = 0;
864 if(c.getRed()+c.getGreen()+c.getBlue()>255*1.5-1) {
865 value = 1;
866 }
867 append(value+" setgray"); //$NON-NLS-1$
868 } else if(getColorDepth()==GRAYSCALE) {
869 float value = ((c.getRed()+c.getGreen()+c.getBlue())/(3*255f));
870 append(value+" setgray"); //$NON-NLS-1$
871 } else {
872 append((c.getRed()/255f)+" "+(c.getGreen()/255f)+" "+(c.getBlue()/255f)+" setrgbcolor"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
873 }
874 }
875
876 /**
877 * Sets the paint mode of this EpsGraphics2D object to overwrite the

Callers 7

EpsGraphics2DMethod · 0.95
draw3DRectMethod · 0.95
fill3DRectMethod · 0.95
setPaintMethod · 0.95
clearRectMethod · 0.95
drawImageMethod · 0.95
appendMethod · 0.45

Calls 5

getColorDepthMethod · 0.95
appendMethod · 0.95
getRedMethod · 0.80
getGreenMethod · 0.80
getBlueMethod · 0.80

Tested by

no test coverage detected