Rename custom color class to ORColor
This commit is contained in:
parent
7fe41ed0ae
commit
9c163fa551
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
@ -1,6 +1,6 @@
|
||||
package net.sf.openrocket.appearance;
|
||||
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
|
||||
/**
|
||||
@ -10,9 +10,9 @@ import net.sf.openrocket.util.MathUtil;
|
||||
* @author Bill Kuker <bkuker@billkuker.com>
|
||||
*/
|
||||
public class Appearance {
|
||||
public static final Appearance MISSING = new Appearance(new Color(0, 0, 0), 1, null);
|
||||
public static final Appearance MISSING = new Appearance(new ORColor(0, 0, 0), 1, null);
|
||||
|
||||
private final Color paint;
|
||||
private final ORColor paint;
|
||||
private final double shine;
|
||||
private final Decal texture;
|
||||
|
||||
@ -23,7 +23,7 @@ public class Appearance {
|
||||
* @param shine shine of the appearance, will be clamped between 0 and 1
|
||||
* @param texture The appearance texture
|
||||
*/
|
||||
public Appearance(final Color paint, final double shine, final Decal texture) {
|
||||
public Appearance(final ORColor paint, final double shine, final Decal texture) {
|
||||
this.paint = paint;
|
||||
this.shine = MathUtil.clamp(shine, 0, 1);
|
||||
this.texture = texture;
|
||||
@ -35,14 +35,14 @@ public class Appearance {
|
||||
* @param paint the color to be used
|
||||
* @param shine shine of the appearance, will be clamped between 0 and 1
|
||||
*/
|
||||
public Appearance(final Color paint, final double shine) {
|
||||
public Appearance(final ORColor paint, final double shine) {
|
||||
this(paint,shine,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color of the appearance
|
||||
*/
|
||||
public Color getPaint() {
|
||||
public ORColor getPaint() {
|
||||
return paint;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package net.sf.openrocket.appearance;
|
||||
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.util.AbstractChangeSource;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@ -22,7 +22,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class AppearanceBuilder extends AbstractChangeSource {
|
||||
|
||||
private Color paint; //current cached color
|
||||
private ORColor paint; //current cached color
|
||||
private double shine; //current cached shine
|
||||
private double offsetU, offsetV;//current offset to be used
|
||||
private double centerU, centerV;//current values for the center of the appearance
|
||||
@ -62,7 +62,7 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
||||
* Clears the builder cache and set to build blank appearances
|
||||
*/
|
||||
private void resetToDefaults() {
|
||||
paint = new Color(187, 187, 187);
|
||||
paint = new ORColor(187, 187, 187);
|
||||
shine = 0.3;
|
||||
offsetU = offsetV = 0;
|
||||
centerU = centerV = 0;
|
||||
@ -144,7 +144,7 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
||||
*
|
||||
* return the color used in the current paint
|
||||
*/
|
||||
public Color getPaint() {
|
||||
public ORColor getPaint() {
|
||||
return paint;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
||||
*
|
||||
* @param paint the new color
|
||||
*/
|
||||
public void setPaint(Color paint) {
|
||||
public void setPaint(ORColor paint) {
|
||||
for (AppearanceBuilder listener : configListeners.values()) {
|
||||
listener.setPaint(paint);
|
||||
}
|
||||
@ -218,7 +218,7 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
||||
|
||||
// Instead of simply setting the alpha, we need to create a new color with the new alpha value, otherwise undoing
|
||||
// the setOpacity will not work correctly. (don't ask me why)
|
||||
Color c = new Color(paint.getRed(), paint.getGreen(), paint.getBlue(), (int) (opacity * 255));
|
||||
ORColor c = new ORColor(paint.getRed(), paint.getGreen(), paint.getBlue(), (int) (opacity * 255));
|
||||
setPaint(c);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
import net.sf.openrocket.rocketcomponent.TubeFinSet;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ public class DefaultAppearance {
|
||||
*/
|
||||
private static Appearance simple(String resource) {
|
||||
return new Appearance(
|
||||
new Color(1, 1, 1),
|
||||
new ORColor(1, 1, 1),
|
||||
0,
|
||||
new Decal(
|
||||
new Coordinate(0, 0),
|
||||
@ -59,7 +59,7 @@ public class DefaultAppearance {
|
||||
* @param resource the file path to the image
|
||||
* @return The appearance with custom color and shine.
|
||||
*/
|
||||
private static Appearance simpleAlpha(Color base, float shine, String resource) {
|
||||
private static Appearance simpleAlpha(ORColor base, float shine, String resource) {
|
||||
return new Appearance(
|
||||
base,
|
||||
shine,
|
||||
@ -80,16 +80,16 @@ public class DefaultAppearance {
|
||||
private static final Appearance CHUTE = simple("/datafiles/textures/chute.jpg");
|
||||
|
||||
|
||||
private static final Appearance ESTES_BT = simpleAlpha(new Color(212, 185, 145), .3f, "/datafiles/textures/spiral-wound-alpha.png");
|
||||
private static final Appearance ESTES_IT = simpleAlpha(new Color(168, 146, 116), .1f, "/datafiles/textures/spiral-wound-alpha.png");
|
||||
private static final Appearance WHITE_BT = simpleAlpha(new Color(240, 240, 240), .3f, "/datafiles/textures/spiral-wound-alpha.png");
|
||||
private static final Appearance ESTES_BT = simpleAlpha(new ORColor(212, 185, 145), .3f, "/datafiles/textures/spiral-wound-alpha.png");
|
||||
private static final Appearance ESTES_IT = simpleAlpha(new ORColor(168, 146, 116), .1f, "/datafiles/textures/spiral-wound-alpha.png");
|
||||
private static final Appearance WHITE_BT = simpleAlpha(new ORColor(240, 240, 240), .3f, "/datafiles/textures/spiral-wound-alpha.png");
|
||||
|
||||
private static final Appearance ESTES_MOTOR = simple("/datafiles/textures/motors/estes.jpg");
|
||||
private static final Appearance AEROTECH_MOTOR = simple("/datafiles/textures/motors/aerotech.png");
|
||||
private static final Appearance KLIMA_MOTOR = simple("/datafiles/textures/motors/klima.jpg");
|
||||
private static final Appearance REUSABLE_MOTOR = simpleAlpha(new Color(195, 60, 50), .6f, "/datafiles/textures/motors/reusable.png");
|
||||
private static final Appearance REUSABLE_MOTOR = simpleAlpha(new ORColor(195, 60, 50), .6f, "/datafiles/textures/motors/reusable.png");
|
||||
|
||||
private static final HashMap<Color, Appearance> plastics = new HashMap<Color, Appearance>();
|
||||
private static final HashMap<ORColor, Appearance> plastics = new HashMap<ORColor, Appearance>();
|
||||
|
||||
/**
|
||||
* gets the appearance correspondent to the plastic with the given color
|
||||
@ -97,7 +97,7 @@ public class DefaultAppearance {
|
||||
* @param c the color of the plastics
|
||||
* @return The plastic appearance with the given color
|
||||
*/
|
||||
private static Appearance getPlastic(Color c) {
|
||||
private static Appearance getPlastic(ORColor c) {
|
||||
if (!plastics.containsKey(c)) {
|
||||
plastics.put(c, new Appearance(c, .3));
|
||||
}
|
||||
@ -120,7 +120,7 @@ public class DefaultAppearance {
|
||||
if (c instanceof LaunchLug)
|
||||
return WHITE_BT;
|
||||
if (c instanceof Transition)
|
||||
return getPlastic(new Color(255, 255, 255));
|
||||
return getPlastic(new ORColor(255, 255, 255));
|
||||
if (c instanceof RadiusRingComponent)
|
||||
return WOOD;
|
||||
if (c instanceof Parachute)
|
||||
@ -130,7 +130,7 @@ public class DefaultAppearance {
|
||||
if (c instanceof MassObject)
|
||||
return WADDING;
|
||||
if ( c instanceof RailButton )
|
||||
return getPlastic(new Color(255, 255, 220));
|
||||
return getPlastic(new ORColor(255, 255, 220));
|
||||
return Appearance.MISSING;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import net.sf.openrocket.file.simplesax.AbstractElementHandler;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
@ -58,7 +58,7 @@ class AppearanceHandler extends AbstractElementHandler {
|
||||
// "alpha" string was present so load the value
|
||||
alpha = Integer.parseInt(a);
|
||||
}
|
||||
builder.setPaint(new Color(red, green, blue, alpha));
|
||||
builder.setPaint(new ORColor(red, green, blue, alpha));
|
||||
return;
|
||||
}
|
||||
if ("shine".equals(element)) {
|
||||
|
@ -5,10 +5,10 @@ import java.util.HashMap;
|
||||
import net.sf.openrocket.logging.Warning;
|
||||
import net.sf.openrocket.logging.WarningSet;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.Reflection;
|
||||
|
||||
//// ColorSetter - sets a Color value
|
||||
//// ColorSetter - sets a ORColor value
|
||||
class ColorSetter implements Setter {
|
||||
private final Reflection.Method setMethod;
|
||||
|
||||
@ -44,7 +44,7 @@ class ColorSetter implements Setter {
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = new Color(r, g, b);
|
||||
ORColor color = new ORColor(r, g, b);
|
||||
setMethod.invoke(c, color);
|
||||
|
||||
if (!s.trim().equals("")) {
|
||||
|
@ -45,7 +45,7 @@ import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
import net.sf.openrocket.rocketcomponent.TubeFinSet;
|
||||
import net.sf.openrocket.util.BugException;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.LineStyle;
|
||||
import net.sf.openrocket.util.Reflection;
|
||||
|
||||
@ -116,7 +116,7 @@ class DocumentConfig {
|
||||
setters.put("RocketComponent:id", new StringSetter(
|
||||
Reflection.findMethod(RocketComponent.class, "setID", String.class)));
|
||||
setters.put("RocketComponent:color", new ColorSetter(
|
||||
Reflection.findMethod(RocketComponent.class, "setColor", Color.class)));
|
||||
Reflection.findMethod(RocketComponent.class, "setColor", ORColor.class)));
|
||||
setters.put("RocketComponent:linestyle", new EnumSetter<LineStyle>(
|
||||
Reflection.findMethod(RocketComponent.class, "setLineStyle", LineStyle.class),
|
||||
LineStyle.class));
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.sf.openrocket.file.openrocket.savers;
|
||||
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -55,7 +55,7 @@ public class PhotoStudioSaver {
|
||||
return elements;
|
||||
}
|
||||
|
||||
private static Color getColor(String content) {
|
||||
private static ORColor getColor(String content) {
|
||||
if (content == null) return null;
|
||||
String[] values = content.split(" ");
|
||||
if (values.length < 4) return null;
|
||||
@ -64,11 +64,11 @@ public class PhotoStudioSaver {
|
||||
int green = Integer.parseInt(values[1]);
|
||||
int blue = Integer.parseInt(values[2]);
|
||||
int alpha = Integer.parseInt(values[3]);
|
||||
return new Color(red, green, blue, alpha);
|
||||
return new ORColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
private static void emitColor(String elementName, List<String> elements, String content) {
|
||||
Color color = getColor(content);
|
||||
ORColor color = getColor(content);
|
||||
if (color != null) {
|
||||
elements.add("<" + elementName + " red=\"" + color.getRed() + "\" green=\"" + color.getGreen()
|
||||
+ "\" blue=\"" + color.getBlue() + "\" alpha=\"" + color.getAlpha() + "\"/>");
|
||||
|
@ -22,7 +22,7 @@ import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||
import net.sf.openrocket.rocketcomponent.position.RadiusPositionable;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.BugException;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.LineStyle;
|
||||
import net.sf.openrocket.util.TextUtil;
|
||||
@ -69,7 +69,7 @@ public class RocketComponentSaver {
|
||||
|
||||
// Save color and line style if significant
|
||||
if (!(c instanceof Rocket || c instanceof ComponentAssembly)) {
|
||||
Color color = c.getColor();
|
||||
ORColor color = c.getColor();
|
||||
emitColor("color", elements, color, 0);
|
||||
|
||||
LineStyle style = c.getLineStyle();
|
||||
@ -156,7 +156,7 @@ public class RocketComponentSaver {
|
||||
}
|
||||
|
||||
private void buildAppearanceElements(List<String> elements, Appearance a) {
|
||||
Color paint = a.getPaint();
|
||||
ORColor paint = a.getPaint();
|
||||
emitColor("paint", elements, paint, 1);
|
||||
appendElement(elements, "shine", a.getShine(), 1);
|
||||
Decal decal = a.getTexture();
|
||||
@ -271,7 +271,7 @@ public class RocketComponentSaver {
|
||||
return elements;
|
||||
}
|
||||
|
||||
private final static void emitColor(String elementName, List<String> elements, Color color, int indents) {
|
||||
private final static void emitColor(String elementName, List<String> elements, ORColor color, int indents) {
|
||||
if (color != null) {
|
||||
elements.add(OpenRocketSaver.INDENT.repeat(Math.max(0, indents)) + "<" + elementName + " red=\"" + color.getRed() + "\" green=\"" + color.getGreen()
|
||||
+ "\" blue=\"" + color.getBlue() + "\" alpha=\"" + color.getAlpha() + "\"/>");
|
||||
|
@ -4,13 +4,12 @@ import net.sf.openrocket.file.motor.AbstractMotorLoader;
|
||||
import net.sf.openrocket.logging.WarningSet;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||
import net.sf.openrocket.rocketcomponent.DeploymentConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.ExternalComponent;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -480,9 +479,9 @@ public class RASAeroCommonConstants {
|
||||
return DeploymentConfiguration.DeployEvent.APOGEE;
|
||||
}
|
||||
|
||||
public static String OPENROCKET_TO_RASAERO_COLOR(Color color) {
|
||||
public static String OPENROCKET_TO_RASAERO_COLOR(ORColor color) {
|
||||
if (color != null) {
|
||||
if (color.equals(Color.BLACK)) {
|
||||
if (color.equals(ORColor.BLACK)) {
|
||||
return "Black"; // Currently the only officially supported color by RASAero
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.sf.openrocket.file.rasaero.importt;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
/**
|
||||
* Handles the 2D outline color handling from RASAero.
|
||||
@ -18,10 +18,10 @@ public abstract class ColorHandler {
|
||||
*/
|
||||
public static void applyRASAeroColor(RocketComponent component, String color) {
|
||||
if ("Black".equals(color)) {
|
||||
component.setColor(Color.BLACK);
|
||||
component.setColor(ORColor.BLACK);
|
||||
return;
|
||||
}
|
||||
// Default to black
|
||||
component.setColor(Color.BLACK);
|
||||
component.setColor(ORColor.BLACK);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||
import net.sf.openrocket.document.Attachment;
|
||||
import net.sf.openrocket.file.DocumentLoadingContext;
|
||||
import net.sf.openrocket.file.rocksim.RockSimCommonConstants;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
public class RockSimAppearanceBuilder extends AppearanceBuilder {
|
||||
|
||||
@ -124,32 +124,32 @@ public class RockSimAppearanceBuilder extends AppearanceBuilder {
|
||||
|
||||
}
|
||||
|
||||
static Color weight(Color c, double w) {
|
||||
return new Color((int) (c.getRed() * w), (int) (c.getGreen() * w), (int) (c.getBlue() * w), c.getAlpha());
|
||||
static ORColor weight(ORColor c, double w) {
|
||||
return new ORColor((int) (c.getRed() * w), (int) (c.getGreen() * w), (int) (c.getBlue() * w), c.getAlpha());
|
||||
}
|
||||
|
||||
static Color parseColor(String s) {
|
||||
static ORColor parseColor(String s) {
|
||||
// blue and white came from a real file.
|
||||
if ("blue".equals(s)) {
|
||||
return new Color(0, 0, 255);
|
||||
return new ORColor(0, 0, 255);
|
||||
}
|
||||
if ("white".equals(s)) {
|
||||
return new Color(255, 255, 255);
|
||||
return new ORColor(255, 255, 255);
|
||||
}
|
||||
// I guessed these are valid color names in Rksim.
|
||||
if ("red".equals(s)) {
|
||||
return new Color(255, 0, 0);
|
||||
return new ORColor(255, 0, 0);
|
||||
}
|
||||
if ("green".equals(s)) {
|
||||
return new Color(0, 255, 0);
|
||||
return new ORColor(0, 255, 0);
|
||||
}
|
||||
if ("black".equals(s)) {
|
||||
return new Color(0, 0, 0);
|
||||
return new ORColor(0, 0, 0);
|
||||
}
|
||||
s = s.replace("rgb(", "");
|
||||
s = s.replace(")", "");
|
||||
String[] ss = s.split(",");
|
||||
return new Color(Integer.parseInt(ss[0]), Integer.parseInt(ss[1]), Integer.parseInt(ss[2]));
|
||||
return new ORColor(Integer.parseInt(ss[0]), Integer.parseInt(ss[1]), Integer.parseInt(ss[2]));
|
||||
}
|
||||
|
||||
public boolean isPreventSeam() {
|
||||
|
@ -6,7 +6,7 @@ import net.sf.openrocket.appearance.DecalImage;
|
||||
import net.sf.openrocket.file.wavefrontobj.DefaultMtl;
|
||||
import net.sf.openrocket.file.wavefrontobj.DefaultObj;
|
||||
import net.sf.openrocket.file.wavefrontobj.DefaultTextureOptions;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -126,7 +126,7 @@ public class AppearanceExporter {
|
||||
}
|
||||
|
||||
private static void applyColoring(Appearance appearance, DefaultMtl material, OBJExportOptions options) {
|
||||
Color color = appearance.getPaint();
|
||||
ORColor color = appearance.getPaint();
|
||||
final float r = convertColorToFloat(color.getRed(), options.isUseSRGB());
|
||||
final float g = convertColorToFloat(color.getGreen(), options.isUseSRGB());
|
||||
final float b = convertColorToFloat(color.getBlue(), options.isUseSRGB());
|
||||
|
@ -17,6 +17,7 @@ import net.sf.openrocket.aerodynamics.FlightConditions;
|
||||
import net.sf.openrocket.logging.WarningSet;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.startup.Preferences;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -30,7 +31,6 @@ import net.sf.openrocket.rocketcomponent.position.RadiusMethod;
|
||||
import net.sf.openrocket.util.ArrayList;
|
||||
import net.sf.openrocket.util.BugException;
|
||||
import net.sf.openrocket.util.ChangeSource;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ComponentChangeAdapter;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.Invalidator;
|
||||
@ -99,8 +99,8 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
*/
|
||||
protected Coordinate position = new Coordinate();
|
||||
|
||||
// Color of the component, null means to use the default color
|
||||
private Color color = null;
|
||||
// ORColor of the component, null means to use the default color
|
||||
private ORColor color = null;
|
||||
private LineStyle lineStyle = null;
|
||||
|
||||
|
||||
@ -520,7 +520,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
* Return the color of the object to use in 2D figures, or <code>null</code>
|
||||
* to use the default color.
|
||||
*/
|
||||
public final Color getColor() {
|
||||
public final ORColor getColor() {
|
||||
mutex.verify();
|
||||
return color;
|
||||
}
|
||||
@ -528,7 +528,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
/**
|
||||
* Set the color of the object to use in 2D figures.
|
||||
*/
|
||||
public final void setColor(Color c) {
|
||||
public final void setColor(ORColor c) {
|
||||
for (RocketComponent listener : configListeners) {
|
||||
listener.setColor(c);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import net.sf.openrocket.simulation.RK4SimulationStepper;
|
||||
import net.sf.openrocket.util.BugException;
|
||||
import net.sf.openrocket.util.BuildProperties;
|
||||
import net.sf.openrocket.util.ChangeSource;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.GeodeticComputationStrategy;
|
||||
import net.sf.openrocket.util.LineStyle;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
@ -907,13 +907,13 @@ public abstract class Preferences implements ChangeSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* get a net.sf.openrocket.util.Color object for the given key.
|
||||
* get a net.sf.openrocket.util.ORColor object for the given key.
|
||||
* @param key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public final Color getColor(String key, Color defaultValue) {
|
||||
Color c = parseColor(getString(key, null));
|
||||
public final ORColor getColor(String key, ORColor defaultValue) {
|
||||
ORColor c = parseColor(getString(key, null));
|
||||
if (c == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
@ -921,20 +921,20 @@ public abstract class Preferences implements ChangeSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* set a net.sf.openrocket.util.Color preference value for the given key.
|
||||
* set a net.sf.openrocket.util.ORColor preference value for the given key.
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public final void putColor(String key, Color value) {
|
||||
public final void putColor(String key, ORColor value) {
|
||||
putString(key, stringifyColor(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to convert a string representation into a net.sf.openrocket.util.Color object.
|
||||
* Helper function to convert a string representation into a net.sf.openrocket.util.ORColor object.
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
protected static Color parseColor(String color) {
|
||||
protected static ORColor parseColor(String color) {
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
@ -945,7 +945,7 @@ public abstract class Preferences implements ChangeSource {
|
||||
int red = MathUtil.clamp(Integer.parseInt(rgb[0]), 0, 255);
|
||||
int green = MathUtil.clamp(Integer.parseInt(rgb[1]), 0, 255);
|
||||
int blue = MathUtil.clamp(Integer.parseInt(rgb[2]), 0, 255);
|
||||
return new Color(red, green, blue);
|
||||
return new ORColor(red, green, blue);
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
}
|
||||
@ -953,12 +953,12 @@ public abstract class Preferences implements ChangeSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to convert a net.sf.openrocket.util.Color object into a
|
||||
* Helper function to convert a net.sf.openrocket.util.ORColor object into a
|
||||
* String before storing in a preference.
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
protected static String stringifyColor(Color color) {
|
||||
protected static String stringifyColor(ORColor color) {
|
||||
String string = color.getRed() + "," + color.getGreen() + "," + color.getBlue();
|
||||
return string;
|
||||
}
|
||||
|
@ -1,84 +1,84 @@
|
||||
package net.sf.openrocket.util;
|
||||
|
||||
public class Color {
|
||||
|
||||
public static Color BLACK = new Color(0,0,0);
|
||||
public static Color INVISIBLE = new Color(1, 1, 1, 0);
|
||||
public static Color DARK_RED = new Color(200, 0, 0);
|
||||
|
||||
private int red;
|
||||
private int green;
|
||||
private int blue;
|
||||
private int alpha;
|
||||
|
||||
public Color( int red, int green, int blue ) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
this.alpha = 255;
|
||||
}
|
||||
|
||||
public Color( int red, int green, int blue, int alpha ) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
public int getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
public void setRed(int red) {
|
||||
this.red = red;
|
||||
}
|
||||
|
||||
public int getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
public void setGreen(int green) {
|
||||
this.green = green;
|
||||
}
|
||||
|
||||
public int getBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
public void setBlue(int blue) {
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
public int getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public void setAlpha(int alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Color [r=" + red + ", g=" + green + ", b=" + blue + ", a=" + alpha + "]";
|
||||
}
|
||||
|
||||
public java.awt.Color toAWTColor() {
|
||||
return new java.awt.Color(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public static Color fromAWTColor(java.awt.Color AWTColor) {
|
||||
return new Color(AWTColor.getRed(), AWTColor.getGreen(), AWTColor.getBlue(), AWTColor.getAlpha());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Color)) {
|
||||
return false;
|
||||
}
|
||||
Color c = (Color) obj;
|
||||
return c.getRed() == getRed() && c.getGreen() == getGreen() && c.getBlue() == getBlue() && c.getAlpha() == getAlpha();
|
||||
}
|
||||
}
|
||||
package net.sf.openrocket.util;
|
||||
|
||||
public class ORColor {
|
||||
|
||||
public static ORColor BLACK = new ORColor(0,0,0);
|
||||
public static ORColor INVISIBLE = new ORColor(1, 1, 1, 0);
|
||||
public static ORColor DARK_RED = new ORColor(200, 0, 0);
|
||||
|
||||
private int red;
|
||||
private int green;
|
||||
private int blue;
|
||||
private int alpha;
|
||||
|
||||
public ORColor(int red, int green, int blue ) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
this.alpha = 255;
|
||||
}
|
||||
|
||||
public ORColor(int red, int green, int blue, int alpha ) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
public int getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
public void setRed(int red) {
|
||||
this.red = red;
|
||||
}
|
||||
|
||||
public int getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
public void setGreen(int green) {
|
||||
this.green = green;
|
||||
}
|
||||
|
||||
public int getBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
public void setBlue(int blue) {
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
public int getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public void setAlpha(int alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ORColor [r=" + red + ", g=" + green + ", b=" + blue + ", a=" + alpha + "]";
|
||||
}
|
||||
|
||||
public java.awt.Color toAWTColor() {
|
||||
return new java.awt.Color(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public static ORColor fromAWTColor(java.awt.Color AWTColor) {
|
||||
return new ORColor(AWTColor.getRed(), AWTColor.getGreen(), AWTColor.getBlue(), AWTColor.getAlpha());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ORColor)) {
|
||||
return false;
|
||||
}
|
||||
ORColor c = (ORColor) obj;
|
||||
return c.getRed() == getRed() && c.getGreen() == getGreen() && c.getBlue() == getBlue() && c.getAlpha() == getAlpha();
|
||||
}
|
||||
}
|
@ -380,8 +380,8 @@ public class TestRockets {
|
||||
return (rnd.nextDouble() * 0.2 + 0.9) * scale;
|
||||
}
|
||||
|
||||
private Color randomColor() {
|
||||
return new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
|
||||
private ORColor randomColor() {
|
||||
return new ORColor(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
|
||||
}
|
||||
|
||||
private <T extends Enum<T>> Enum<T> randomEnum(Class<T> c) {
|
||||
@ -1522,7 +1522,7 @@ public class TestRockets {
|
||||
|
||||
// make body tube with an appearance setting
|
||||
BodyTube bodyTube = new BodyTube(12, 1, 0.05);
|
||||
Appearance appearance = new Appearance(new Color(100, 25, 50), 1, null);
|
||||
Appearance appearance = new Appearance(new ORColor(100, 25, 50), 1, null);
|
||||
bodyTube.setAppearance(appearance);
|
||||
stage.addChild(bodyTube);
|
||||
|
||||
|
@ -11,6 +11,7 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.AerodynamicForces;
|
||||
@ -23,7 +24,6 @@ import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet.CrossSection;
|
||||
import net.sf.openrocket.rocketcomponent.Transition.Shape;
|
||||
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.LineStyle;
|
||||
import net.sf.openrocket.util.Transformation;
|
||||
@ -38,7 +38,7 @@ public class FreeformFinSetTest extends BaseTestCase {
|
||||
sourceSet.setBaseRotation(1.1);
|
||||
sourceSet.setCantAngle(0.001);
|
||||
sourceSet.setCGOverridden(true);
|
||||
sourceSet.setColor(Color.BLACK);
|
||||
sourceSet.setColor(ORColor.BLACK);
|
||||
sourceSet.setComment("cmt");
|
||||
sourceSet.setCrossSection(CrossSection.ROUNDED);
|
||||
sourceSet.setFinCount(5);
|
||||
@ -183,7 +183,7 @@ public class FreeformFinSetTest extends BaseTestCase {
|
||||
assertEquals(0.001, finSet.getCantAngle(), EPSILON);
|
||||
assertTrue(finSet.isCGOverridden());
|
||||
assertTrue(finSet.isMassOverridden());
|
||||
assertEquals(Color.BLACK, finSet.getColor());
|
||||
assertEquals(ORColor.BLACK, finSet.getColor());
|
||||
assertEquals("cmt", finSet.getComment());
|
||||
assertEquals(CrossSection.ROUNDED, finSet.getCrossSection());
|
||||
assertEquals(5, finSet.getFinCount());
|
||||
@ -220,7 +220,7 @@ public class FreeformFinSetTest extends BaseTestCase {
|
||||
assertEquals(0.001, finSet.getCantAngle(), EPSILON);
|
||||
assertTrue(finSet.isCGOverridden());
|
||||
assertTrue(finSet.isMassOverridden());
|
||||
assertEquals(Color.BLACK, finSet.getColor());
|
||||
assertEquals(ORColor.BLACK, finSet.getColor());
|
||||
assertEquals("cmt", finSet.getComment());
|
||||
assertEquals(CrossSection.ROUNDED, finSet.getCrossSection());
|
||||
assertEquals(5, finSet.getFinCount());
|
||||
|
@ -1,12 +1,10 @@
|
||||
package net.sf.openrocket.file.photo;
|
||||
|
||||
import net.sf.openrocket.file.openrocket.importt.OpenRocketHandler;
|
||||
import net.sf.openrocket.gui.figure3d.TextureCache;
|
||||
import net.sf.openrocket.gui.figure3d.photo.PhotoSettings;
|
||||
import net.sf.openrocket.gui.figure3d.photo.sky.Sky;
|
||||
import net.sf.openrocket.gui.figure3d.photo.sky.builtin.*;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -94,7 +92,7 @@ public class PhotoStudioGetter {
|
||||
return;
|
||||
}
|
||||
if ("sunlight".equals(element)) {
|
||||
Color sunlight = getColor(content);
|
||||
ORColor sunlight = getColor(content);
|
||||
p.setSunlight(sunlight);
|
||||
return;
|
||||
}
|
||||
@ -105,7 +103,7 @@ public class PhotoStudioGetter {
|
||||
}
|
||||
|
||||
if ("skyColor".equals(element)) {
|
||||
Color skyColor = getColor(content);
|
||||
ORColor skyColor = getColor(content);
|
||||
p.setSkyColor(skyColor);
|
||||
return;
|
||||
}
|
||||
@ -121,7 +119,7 @@ public class PhotoStudioGetter {
|
||||
return;
|
||||
}
|
||||
if ("flameColor".equals(element)) {
|
||||
Color flameColor = getColor(content);
|
||||
ORColor flameColor = getColor(content);
|
||||
p.setFlameColor(flameColor);
|
||||
return;
|
||||
}
|
||||
@ -131,7 +129,7 @@ public class PhotoStudioGetter {
|
||||
return;
|
||||
}
|
||||
if ("smokeColor".equals(element)) {
|
||||
Color smokeColor = getColor(content);
|
||||
ORColor smokeColor = getColor(content);
|
||||
p.setSmokeColor(smokeColor);
|
||||
return;
|
||||
}
|
||||
@ -190,7 +188,7 @@ public class PhotoStudioGetter {
|
||||
}
|
||||
}
|
||||
|
||||
private Color getColor(String content) {
|
||||
private ORColor getColor(String content) {
|
||||
String[] values = content.split(" ");
|
||||
if (values.length < 4) return null;
|
||||
|
||||
@ -198,6 +196,6 @@ public class PhotoStudioGetter {
|
||||
int green = Integer.parseInt(values[1]);
|
||||
int blue = Integer.parseInt(values[2]);
|
||||
int alpha = Integer.parseInt(values[3]);
|
||||
return new Color(red, green, blue, alpha);
|
||||
return new ORColor(red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.sf.openrocket.file.photo;
|
||||
|
||||
import net.sf.openrocket.gui.figure3d.photo.PhotoSettings;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -56,7 +56,7 @@ public class PhotoStudioSetter {
|
||||
return photoSettings;
|
||||
}
|
||||
|
||||
private static String getColor(Color color) {
|
||||
private static String getColor(ORColor color) {
|
||||
if (color == null) return "";
|
||||
return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.awt.Color;
|
||||
import javax.swing.Icon;
|
||||
|
||||
import net.sf.openrocket.gui.util.ColorConversion;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
/**
|
||||
* An Icon that displays a specific color, suitable for drawing into a button.
|
||||
@ -18,7 +19,7 @@ public class ColorIcon implements Icon {
|
||||
this.color = c;
|
||||
}
|
||||
|
||||
public ColorIcon(net.sf.openrocket.util.Color c){
|
||||
public ColorIcon(ORColor c){
|
||||
this.color = ColorConversion.toAwtColor(c);
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,7 @@ import net.sf.openrocket.unit.GeneralUnit;
|
||||
import net.sf.openrocket.unit.Unit;
|
||||
import net.sf.openrocket.unit.UnitGroup;
|
||||
import net.sf.openrocket.util.LineStyle;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.StateChangeListener;
|
||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||
|
||||
@ -138,7 +139,7 @@ public class AppearancePanel extends JPanel {
|
||||
private void changeComponentColor(Color color) {
|
||||
try {
|
||||
final Method setMethod = o.getClass().getMethod(
|
||||
"set" + valueName, net.sf.openrocket.util.Color.class);
|
||||
"set" + valueName, ORColor.class);
|
||||
if (color == null)
|
||||
return;
|
||||
try {
|
||||
@ -164,7 +165,7 @@ public class AppearancePanel extends JPanel {
|
||||
try {
|
||||
final Method getMethod = o.getClass().getMethod(
|
||||
"get" + valueName);
|
||||
net.sf.openrocket.util.Color c = (net.sf.openrocket.util.Color) getMethod
|
||||
ORColor c = (ORColor) getMethod
|
||||
.invoke(o);
|
||||
|
||||
Color awtColor = ColorConversion.toAwtColor(c);
|
||||
@ -261,7 +262,7 @@ public class AppearancePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
net.sf.openrocket.util.Color figureColor = c.getColor();
|
||||
ORColor figureColor = c.getColor();
|
||||
if (figureColor == null) {
|
||||
figureColor = ((SwingPreferences) Application.getPreferences()).getDefaultColor(c.getClass());
|
||||
}
|
||||
@ -276,7 +277,7 @@ public class AppearancePanel extends JPanel {
|
||||
c.addChangeListener(new StateChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(EventObject e) {
|
||||
net.sf.openrocket.util.Color col = c.getColor();
|
||||
ORColor col = c.getColor();
|
||||
if (col == null) {
|
||||
col = ((SwingPreferences) Application.getPreferences()).getDefaultColor(c.getClass());
|
||||
}
|
||||
@ -335,7 +336,7 @@ public class AppearancePanel extends JPanel {
|
||||
add(saveAsDefault, "span 2, align right, wrap");
|
||||
}
|
||||
|
||||
{// Figure Color
|
||||
{// Figure ORColor
|
||||
add(new JLabel(trans.get("RocketCompCfg.lbl.Componentcolor")));
|
||||
fDefault.addEnableComponent(figureColorButton, false);
|
||||
add(figureColorButton);
|
||||
@ -617,7 +618,7 @@ public class AppearancePanel extends JPanel {
|
||||
}
|
||||
|
||||
// TODO: move the separate columns in two separate panels instead of adding them in a zig-zag way
|
||||
// Color
|
||||
// ORColor
|
||||
panel.add(new JLabel(trans.get("AppearanceCfg.lbl.color.Color")));
|
||||
mDefault.addEnableComponent(colorButton, false);
|
||||
panel.add(colorButton);
|
||||
|
@ -275,7 +275,7 @@ public class InnerTubeConfig extends RocketComponentConfig {
|
||||
subPanel.add(new JLabel(trans.get("InnerTubeCfg.lbl.Selectclustercfg")), "spanx, wrap");
|
||||
subPanel.add(new ClusterSelectionPanel((InnerTube) component), "spanx, wrap");
|
||||
// JPanel clusterSelection = new ClusterSelectionPanel((InnerTube)component);
|
||||
// clusterSelection.setBackground(Color.blue);
|
||||
// clusterSelection.setBackground(ORColor.blue);
|
||||
// subPanel.add(clusterSelection);
|
||||
|
||||
panel.add(subPanel);
|
||||
@ -522,7 +522,7 @@ class ClusterSelectionPanel extends JPanel {
|
||||
setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));
|
||||
setMaximumSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));
|
||||
setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
||||
// setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||
// setBorder(BorderFactory.createLineBorder(ORColor.BLACK, 1));
|
||||
setToolTipText(config.getXMLName());
|
||||
component.addChangeListener(this);
|
||||
addMouseListener(this);
|
||||
|
@ -19,7 +19,7 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
public class FigureRenderer extends RocketRenderer {
|
||||
private final float[] color = new float[4];
|
||||
@ -70,13 +70,13 @@ public class FigureRenderer extends RocketRenderer {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final HashMap<Class<?>, Color> defaultColorCache = new HashMap<Class<?>, Color>();
|
||||
private static final HashMap<Class<?>, ORColor> defaultColorCache = new HashMap<Class<?>, ORColor>();
|
||||
|
||||
@Override
|
||||
public void renderComponent(GL2 gl, Geometry geom, float alpha) {
|
||||
RocketComponent c = geom.getComponent();
|
||||
gl.glLightModeli(GL2ES1.GL_LIGHT_MODEL_TWO_SIDE, 1);
|
||||
Color figureColor = c.getColor();
|
||||
ORColor figureColor = c.getColor();
|
||||
if (figureColor == null) {
|
||||
if (defaultColorCache.containsKey(c.getClass())) {
|
||||
figureColor = defaultColorCache.get(c.getClass());
|
||||
@ -148,7 +148,7 @@ public class FigureRenderer extends RocketRenderer {
|
||||
return 20;
|
||||
}
|
||||
|
||||
protected static void convertColor(Color color, float[] out) {
|
||||
protected static void convertColor(ORColor color, float[] out) {
|
||||
if (color == null) {
|
||||
out[0] = 1;
|
||||
out[1] = 1;
|
||||
|
@ -16,7 +16,7 @@ import net.sf.openrocket.gui.figure3d.geometry.Geometry.Surface;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.rocketcomponent.InsideColorComponent;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
import com.jogamp.opengl.util.texture.Texture;
|
||||
|
||||
@ -237,7 +237,7 @@ public class RealisticRenderer extends RocketRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
protected static void convertColor(Color color, float[] out) {
|
||||
protected static void convertColor(ORColor color, float[] out) {
|
||||
if (color == null) {
|
||||
out[0] = 1;
|
||||
out[1] = 1;
|
||||
|
@ -32,6 +32,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -54,7 +55,6 @@ import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.startup.Preferences;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
import net.sf.openrocket.util.StateChangeListener;
|
||||
@ -374,7 +374,7 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
||||
return image;
|
||||
}
|
||||
|
||||
private static void convertColor(Color color, float[] out) {
|
||||
private static void convertColor(ORColor color, float[] out) {
|
||||
if (color == null) {
|
||||
out[0] = 1;
|
||||
out[1] = 1;
|
||||
@ -395,7 +395,7 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
||||
* @param ratio blend ratio. 0 = full color 1, 0.5 = mid-blend, 1 = full color 2
|
||||
* @return blended color
|
||||
*/
|
||||
private static Color blendColors(Color color1, Color color2, double ratio) {
|
||||
private static ORColor blendColors(ORColor color1, ORColor color2, double ratio) {
|
||||
if (ratio < 0 || ratio > 1) {
|
||||
throw new IllegalArgumentException("Blend ratio must be between 0 and 1");
|
||||
}
|
||||
@ -407,7 +407,7 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
||||
int b = (int) ((color1.getBlue() * inverseRatio) + (color2.getBlue() * ratio));
|
||||
int a = (int) ((color1.getAlpha() * inverseRatio) + (color2.getAlpha() * ratio));
|
||||
|
||||
return new Color(r, g, b, a);
|
||||
return new ORColor(r, g, b, a);
|
||||
}
|
||||
|
||||
private void draw(final GLAutoDrawable drawable, float dx, boolean useFakeTransparencyRendering) {
|
||||
@ -442,7 +442,7 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
||||
// artificially by blending the sky color with white (= color that is rendered as transparent background)
|
||||
if (useFakeTransparencyRendering && !Application.getPreferences().getBoolean(
|
||||
Preferences.OPENGL_USE_FBO, false)) {
|
||||
convertColor(blendColors(p.getSkyColor(), new Color(255, 255, 255, 0), 1-p.getSkyColorOpacity()),
|
||||
convertColor(blendColors(p.getSkyColor(), new ORColor(255, 255, 255, 0), 1-p.getSkyColorOpacity()),
|
||||
color);
|
||||
} else {
|
||||
convertColor(p.getSkyColor(), color);
|
||||
|
@ -4,7 +4,7 @@ import net.sf.openrocket.gui.figure3d.photo.exhaust.FlameRenderer.FlameSettings;
|
||||
import net.sf.openrocket.gui.figure3d.photo.sky.Sky;
|
||||
import net.sf.openrocket.gui.figure3d.photo.sky.builtin.Mountains;
|
||||
import net.sf.openrocket.util.AbstractChangeSource;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
|
||||
public class PhotoSettings extends AbstractChangeSource implements FlameSettings {
|
||||
@ -20,18 +20,18 @@ public class PhotoSettings extends AbstractChangeSource implements FlameSettings
|
||||
|
||||
private double lightAlt = .35;
|
||||
private double lightAz = -1;
|
||||
private Color sunlight = new Color(255, 255, 255);
|
||||
private ORColor sunlight = new ORColor(255, 255, 255);
|
||||
private double ambiance = .3f;
|
||||
|
||||
private Color skyColor = new Color(55, 95, 155);
|
||||
private ORColor skyColor = new ORColor(55, 95, 155);
|
||||
private double skyColorOpacity = 1.0;
|
||||
|
||||
|
||||
private boolean motionBlurred = false;
|
||||
private boolean flame = false;
|
||||
private Color flameColor = new Color(255, 100, 50);
|
||||
private ORColor flameColor = new ORColor(255, 100, 50);
|
||||
private boolean smoke = false;
|
||||
private Color smokeColor = new Color(230, 230, 230, 102);
|
||||
private ORColor smokeColor = new ORColor(230, 230, 230, 102);
|
||||
private boolean sparks = false;
|
||||
private double exhaustScale = 1.0;
|
||||
private double flameAspectRatio = 1.0;
|
||||
@ -163,11 +163,11 @@ public class PhotoSettings extends AbstractChangeSource implements FlameSettings
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
public Color getSunlight() {
|
||||
public ORColor getSunlight() {
|
||||
return sunlight;
|
||||
}
|
||||
|
||||
public void setSunlight(Color sunlight) {
|
||||
public void setSunlight(ORColor sunlight) {
|
||||
this.sunlight = sunlight;
|
||||
fireChangeEvent();
|
||||
}
|
||||
@ -181,11 +181,11 @@ public class PhotoSettings extends AbstractChangeSource implements FlameSettings
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
public Color getSkyColor() {
|
||||
public ORColor getSkyColor() {
|
||||
return skyColor;
|
||||
}
|
||||
|
||||
public void setSkyColor(Color skyColor) {
|
||||
public void setSkyColor(ORColor skyColor) {
|
||||
this.skyColor = skyColor;
|
||||
this.skyColorOpacity = skyColor.getAlpha() / 255f;
|
||||
fireChangeEvent();
|
||||
@ -201,20 +201,20 @@ public class PhotoSettings extends AbstractChangeSource implements FlameSettings
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
public Color getFlameColor() {
|
||||
public ORColor getFlameColor() {
|
||||
return flameColor;
|
||||
}
|
||||
|
||||
public void setFlameColor(Color flameColor) {
|
||||
public void setFlameColor(ORColor flameColor) {
|
||||
this.flameColor = flameColor;
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
public Color getSmokeColor() {
|
||||
public ORColor getSmokeColor() {
|
||||
return smokeColor;
|
||||
}
|
||||
|
||||
public void setSmokeColor(Color smokeColor) {
|
||||
public void setSmokeColor(ORColor smokeColor) {
|
||||
this.smokeColor = smokeColor;
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ import net.sf.openrocket.gui.util.ColorConversion;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.unit.UnitGroup;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.StateChangeListener;
|
||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||
|
||||
@ -71,7 +72,7 @@ public class PhotoSettingsConfig extends JTabbedPane {
|
||||
*/
|
||||
private void changeComponentColor(Color color) {
|
||||
try {
|
||||
final Method setMethod = o.getClass().getMethod("set" + valueName, net.sf.openrocket.util.Color.class);
|
||||
final Method setMethod = o.getClass().getMethod("set" + valueName, ORColor.class);
|
||||
if (color == null)
|
||||
return;
|
||||
try {
|
||||
@ -90,7 +91,7 @@ public class PhotoSettingsConfig extends JTabbedPane {
|
||||
public void actionPerformed(ActionEvent colorClickEvent) {
|
||||
try {
|
||||
final Method getMethod = o.getClass().getMethod("get" + valueName);
|
||||
net.sf.openrocket.util.Color c = (net.sf.openrocket.util.Color) getMethod.invoke(o);
|
||||
ORColor c = (ORColor) getMethod.invoke(o);
|
||||
Color awtColor = ColorConversion.toAwtColor(c);
|
||||
colorChooser.setColor(awtColor);
|
||||
|
||||
|
@ -123,6 +123,7 @@ import java.util.Random;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -137,7 +138,6 @@ import com.jogamp.opengl.util.texture.Texture;
|
||||
import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
|
||||
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.util.Color;
|
||||
|
||||
public final class FlameRenderer {
|
||||
|
||||
@ -146,11 +146,11 @@ public final class FlameRenderer {
|
||||
|
||||
public boolean isFlame();
|
||||
|
||||
public Color getFlameColor();
|
||||
public ORColor getFlameColor();
|
||||
|
||||
public boolean isSmoke();
|
||||
|
||||
public Color getSmokeColor();
|
||||
public ORColor getSmokeColor();
|
||||
|
||||
public double getFlameAspectRatio();
|
||||
|
||||
@ -270,7 +270,7 @@ public final class FlameRenderer {
|
||||
|
||||
}
|
||||
|
||||
private static void convertColor(Color color, float[] out) {
|
||||
private static void convertColor(ORColor color, float[] out) {
|
||||
if (color == null) {
|
||||
out[0] = 1;
|
||||
out[1] = 1;
|
||||
@ -376,7 +376,7 @@ public final class FlameRenderer {
|
||||
shaderprogram = 0;
|
||||
}
|
||||
|
||||
private static void trail(GL2 gl, Func radius, Func dZ, Func alpha, float LEN, int P, Color color, float scale) {
|
||||
private static void trail(GL2 gl, Func radius, Func dZ, Func alpha, float LEN, int P, ORColor color, float scale) {
|
||||
float[] c = new float[4];
|
||||
convertColor(color, c);
|
||||
|
||||
|
@ -35,7 +35,7 @@ import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.Pair;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -981,8 +981,8 @@ public class RocketActions {
|
||||
}
|
||||
|
||||
private boolean isAppearanceEqual(Appearance app1, Appearance app2) {
|
||||
Color color1 = app1.getPaint();
|
||||
Color color2 = app2.getPaint();
|
||||
ORColor color1 = app1.getPaint();
|
||||
ORColor color2 = app2.getPaint();
|
||||
|
||||
if (color1 == null && color2 == null) {
|
||||
return true;
|
||||
|
@ -3,11 +3,10 @@ package net.sf.openrocket.gui.rocketfigure;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
|
||||
import net.sf.openrocket.rocketcomponent.ParallelStage;
|
||||
import net.sf.openrocket.rocketcomponent.PodSet;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||
import net.sf.openrocket.rocketcomponent.position.RadiusMethod;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.Transformation;
|
||||
|
||||
import java.awt.Shape;
|
||||
@ -40,7 +39,7 @@ public class ComponentAssemblyShapes extends RocketComponentShape {
|
||||
Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(correctedTransform, markerRadius);
|
||||
RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component);
|
||||
|
||||
shapes[shapes.length - 1].setColor(Color.INVISIBLE);
|
||||
shapes[shapes.length - 1].setColor(ORColor.INVISIBLE);
|
||||
|
||||
return shapes;
|
||||
}
|
||||
@ -64,7 +63,7 @@ public class ComponentAssemblyShapes extends RocketComponentShape {
|
||||
Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(correctedTransform, markerRadius);
|
||||
RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component);
|
||||
|
||||
shapes[shapes.length - 1].setColor(Color.INVISIBLE);
|
||||
shapes[shapes.length - 1].setColor(ORColor.INVISIBLE);
|
||||
|
||||
return shapes;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.util.Arrays;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.RailButton;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.Transformation;
|
||||
|
||||
@ -145,7 +145,7 @@ public class RailButtonShapes extends RocketComponentShape {
|
||||
RocketComponentShape[] shapesInvis = RocketComponentShape.toArray(new Shape[]{ pathInvis }, component);
|
||||
|
||||
for (RocketComponentShape s : shapesInvis) {
|
||||
s.setColor(Color.INVISIBLE);
|
||||
s.setColor(ORColor.INVISIBLE);
|
||||
}
|
||||
|
||||
RocketComponentShape[] total = Arrays.copyOf(shapes, shapes.length + shapesInvis.length);
|
||||
|
@ -5,7 +5,7 @@ import java.awt.Shape;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import net.sf.openrocket.util.LineStyle;
|
||||
import net.sf.openrocket.util.Transformation;
|
||||
|
||||
@ -17,7 +17,7 @@ public class RocketComponentShape {
|
||||
|
||||
final public boolean hasShape;
|
||||
final public Shape shape;
|
||||
public net.sf.openrocket.util.Color color;
|
||||
public ORColor color;
|
||||
final public LineStyle lineStyle;
|
||||
final public RocketComponent component;
|
||||
|
||||
@ -64,11 +64,11 @@ public class RocketComponentShape {
|
||||
return new RocketComponentShape[0];
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
public ORColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
public void setColor(ORColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import net.sf.openrocket.gui.util.UITheme;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.rocketcomponent.ParallelStage;
|
||||
import net.sf.openrocket.rocketcomponent.PodSet;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -274,7 +275,7 @@ public class RocketFigure extends AbstractScaleFigure {
|
||||
}
|
||||
|
||||
// Set component color and line style
|
||||
net.sf.openrocket.util.Color color = rcs.color;
|
||||
ORColor color = rcs.color;
|
||||
if (color == null) {
|
||||
color = ((SwingPreferences) Application.getPreferences()).getDefaultColor(c.getClass());
|
||||
}
|
||||
@ -455,7 +456,7 @@ public class RocketFigure extends AbstractScaleFigure {
|
||||
final RocketPanel.VIEW_TYPE viewType,
|
||||
final RocketComponent component,
|
||||
final Transformation transformation,
|
||||
final net.sf.openrocket.util.Color color) {
|
||||
final ORColor color) {
|
||||
Reflection.Method m;
|
||||
|
||||
if ((component instanceof Rocket) || (component instanceof AxialStage && !(component instanceof ParallelStage))){
|
||||
@ -491,7 +492,7 @@ public class RocketFigure extends AbstractScaleFigure {
|
||||
|
||||
if (color != null) {
|
||||
for (RocketComponentShape rcs : returnValue) {
|
||||
if (rcs.getColor() == net.sf.openrocket.util.Color.INVISIBLE) continue; // don't change the color of invisible (often selection) components
|
||||
if (rcs.getColor() == ORColor.INVISIBLE) continue; // don't change the color of invisible (often selection) components
|
||||
rcs.setColor(color);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,20 @@
|
||||
package net.sf.openrocket.gui.util;
|
||||
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
|
||||
public class ColorConversion {
|
||||
|
||||
public static java.awt.Color toAwtColor( net.sf.openrocket.util.Color c ) {
|
||||
public static java.awt.Color toAwtColor( ORColor c ) {
|
||||
if ( c == null ) {
|
||||
return null;
|
||||
}
|
||||
return new java.awt.Color(c.getRed(),c.getGreen(),c.getBlue(),c.getAlpha());
|
||||
}
|
||||
|
||||
public static net.sf.openrocket.util.Color fromAwtColor( java.awt.Color c ) {
|
||||
public static ORColor fromAwtColor(java.awt.Color c ) {
|
||||
if ( c == null ) {
|
||||
return null;
|
||||
}
|
||||
return new net.sf.openrocket.util.Color( c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
|
||||
return new ORColor( c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import net.sf.openrocket.rocketcomponent.RecoveryDevice;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.TubeFinSet;
|
||||
import net.sf.openrocket.simulation.SimulationOptionsInterface;
|
||||
import net.sf.openrocket.util.ORColor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -406,20 +407,20 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences impl
|
||||
storeVersion();
|
||||
}
|
||||
|
||||
public net.sf.openrocket.util.Color getDefaultColor(Class<? extends RocketComponent> c) {
|
||||
public ORColor getDefaultColor(Class<? extends RocketComponent> c) {
|
||||
String color = get("componentColors", c, DEFAULT_COLORS);
|
||||
if (color == null)
|
||||
return net.sf.openrocket.util.Color.fromAWTColor(getUIThemeAsTheme().getTextColor());
|
||||
return ORColor.fromAWTColor(getUIThemeAsTheme().getTextColor());
|
||||
|
||||
net.sf.openrocket.util.Color clr = parseColor(color);
|
||||
ORColor clr = parseColor(color);
|
||||
if (clr != null) {
|
||||
return clr;
|
||||
} else {
|
||||
return net.sf.openrocket.util.Color.fromAWTColor(getUIThemeAsTheme().getTextColor());
|
||||
return ORColor.fromAWTColor(getUIThemeAsTheme().getTextColor());
|
||||
}
|
||||
}
|
||||
|
||||
public final void setDefaultColor(Class<? extends RocketComponent> c, net.sf.openrocket.util.Color color) {
|
||||
public final void setDefaultColor(Class<? extends RocketComponent> c, ORColor color) {
|
||||
if (color == null)
|
||||
return;
|
||||
putString("componentColors", c.getSimpleName(), stringifyColor(color));
|
||||
@ -682,12 +683,12 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences impl
|
||||
}
|
||||
|
||||
/**
|
||||
* this class returns a java.awt.Color object for the specified key.
|
||||
* you can pass (java.awt.Color) null to the second argument to
|
||||
* this class returns a java.awt.ORColor object for the specified key.
|
||||
* you can pass (java.awt.ORColor) null to the second argument to
|
||||
* disambiguate
|
||||
*/
|
||||
public Color getColor(String key, Color defaultValue) {
|
||||
net.sf.openrocket.util.Color c = super.getColor(key, (net.sf.openrocket.util.Color) null);
|
||||
ORColor c = super.getColor(key, (ORColor) null);
|
||||
if (c == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
@ -698,7 +699,7 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences impl
|
||||
*
|
||||
*/
|
||||
public void putColor(String key, Color value) {
|
||||
net.sf.openrocket.util.Color c = ColorConversion.fromAwtColor(value);
|
||||
ORColor c = ColorConversion.fromAwtColor(value);
|
||||
super.putColor(key, c);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user