Simplify the default appearances. I am not ready to organize them into
classes or factories or what have you, yet.
This commit is contained in:
parent
8dd0a6abc1
commit
28127b122d
Binary file not shown.
Before Width: | Height: | Size: 1023 B After Width: | Height: | Size: 2.0 KiB |
BIN
core/resources/datafiles/textures/wood.png
Normal file
BIN
core/resources/datafiles/textures/wood.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
@ -1,23 +0,0 @@
|
||||
package net.sf.openrocket.appearance.defaults;
|
||||
|
||||
import net.sf.openrocket.appearance.Appearance;
|
||||
import net.sf.openrocket.appearance.Decal;
|
||||
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
class Balsa extends Appearance {
|
||||
public static final Balsa INSTANCE = new Balsa();
|
||||
|
||||
private Balsa() {
|
||||
super(
|
||||
new Color(1, 1, 1),
|
||||
0,
|
||||
new Decal(
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(1, 1),
|
||||
0,
|
||||
new ResourceDecalImage("/datafiles/textures/balsa.png"), EdgeMode.REPEAT));
|
||||
}
|
||||
}
|
@ -1,19 +1,86 @@
|
||||
package net.sf.openrocket.appearance.defaults;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.sf.openrocket.appearance.Appearance;
|
||||
import net.sf.openrocket.appearance.Decal;
|
||||
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||
import net.sf.openrocket.rocketcomponent.LaunchLug;
|
||||
import net.sf.openrocket.rocketcomponent.RadiusRingComponent;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
public class DefaultAppearance {
|
||||
|
||||
private static Appearance BALSA = new
|
||||
Appearance(
|
||||
new Color(1, 1, 1),
|
||||
0,
|
||||
new Decal(
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(1, 1),
|
||||
0,
|
||||
new ResourceDecalImage("/datafiles/textures/balsa.png"), EdgeMode.REPEAT));
|
||||
|
||||
private static Appearance WOOD = new
|
||||
Appearance(
|
||||
new Color(1, 1, 1),
|
||||
0,
|
||||
new Decal(
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(1, 1),
|
||||
0,
|
||||
new ResourceDecalImage("/datafiles/textures/wood.png"), EdgeMode.REPEAT));
|
||||
|
||||
public static final Appearance ESTES_BT = new Appearance(
|
||||
new Color(212, 185, 145),
|
||||
.3,
|
||||
new Decal(
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(1, 3),
|
||||
0,
|
||||
new ResourceDecalImage("/datafiles/textures/spiral-wound-alpha.png"), EdgeMode.REPEAT));
|
||||
|
||||
public static final Appearance WHITE_BT = new Appearance(
|
||||
new Color(240, 240, 240),
|
||||
.3,
|
||||
new Decal(
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(1, 3),
|
||||
0,
|
||||
new ResourceDecalImage("/datafiles/textures/spiral-wound-alpha.png"), EdgeMode.REPEAT));
|
||||
|
||||
|
||||
private static HashMap<Color, Appearance> plastics = new HashMap<Color, Appearance>();
|
||||
|
||||
public static Appearance getPlastic(Color c) {
|
||||
if (!plastics.containsKey(c)) {
|
||||
plastics.put(c, new Appearance(c, .3));
|
||||
}
|
||||
return plastics.get(c);
|
||||
}
|
||||
|
||||
public static Appearance getDefaultAppearance(RocketComponent c) {
|
||||
if (c instanceof BodyTube)
|
||||
return SpiralWound.ESTES_BT;
|
||||
if (c instanceof BodyTube || c instanceof InnerTube || c instanceof TubeCoupler)
|
||||
return ESTES_BT;
|
||||
if (c instanceof FinSet)
|
||||
return Balsa.INSTANCE;
|
||||
return BALSA;
|
||||
if (c instanceof LaunchLug)
|
||||
return SpiralWound.WHITE;
|
||||
return WHITE_BT;
|
||||
if (c instanceof Transition)
|
||||
return getPlastic(new Color(255, 255, 255));
|
||||
if (c instanceof RadiusRingComponent)
|
||||
return WOOD;
|
||||
return Appearance.MISSING;
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
package net.sf.openrocket.appearance.defaults;
|
||||
|
||||
import net.sf.openrocket.appearance.Appearance;
|
||||
import net.sf.openrocket.appearance.Decal;
|
||||
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||
import net.sf.openrocket.util.Color;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
class SpiralWound extends Appearance {
|
||||
|
||||
public static final SpiralWound ESTES_BT = new SpiralWound(new Color(212, 185, 145), .3, 45);
|
||||
public static final SpiralWound BLUE = new SpiralWound(new Color(212, 185, 145), .3, 45);
|
||||
public static final SpiralWound WHITE = new SpiralWound(new Color(240, 240, 240), .3, 45);
|
||||
|
||||
public SpiralWound(Color paint, double shine, double angle) {
|
||||
super(
|
||||
paint,
|
||||
shine,
|
||||
new Decal(
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(0, 0),
|
||||
new Coordinate(1, 1),
|
||||
0,
|
||||
new ResourceDecalImage("/datafiles/textures/spiral-wound-alpha.png"), EdgeMode.REPEAT));
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ import javax.swing.SwingUtilities;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.appearance.AppearanceBuilder;
|
||||
import net.sf.openrocket.appearance.Decal.EdgeMode;
|
||||
import net.sf.openrocket.appearance.defaults.DefaultAppearance;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.gui.SpinnerEditor;
|
||||
import net.sf.openrocket.gui.adaptors.BooleanModel;
|
||||
@ -116,7 +117,7 @@ public class AppearancePanel extends JPanel {
|
||||
public AppearancePanel(final OpenRocketDocument document, final RocketComponent c) {
|
||||
super(new MigLayout("fill", "[150][grow][150][grow]"));
|
||||
|
||||
ab = new AppearanceBuilder(c.getAppearance());
|
||||
ab = new AppearanceBuilder(c.getAppearance() != null ? c.getAppearance() : DefaultAppearance.getDefaultAppearance(c));
|
||||
|
||||
net.sf.openrocket.util.Color figureColor = c.getColor();
|
||||
if (figureColor == null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user