[fixes #905] use of InsideColorComponentHandler
This commit is contained in:
parent
46d9841947
commit
744dbeb9c7
@ -293,7 +293,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
||||
*/
|
||||
private boolean hasDecalInside(RocketComponent comp, DecalImage img) {
|
||||
if (comp instanceof InsideColorComponent) {
|
||||
Appearance a = ((InsideColorComponent)comp).getInsideAppearance();
|
||||
Appearance a = ((InsideColorComponent)comp).getInsideColorComponentHandler().getInsideAppearance();
|
||||
if (a == null)
|
||||
return false;
|
||||
Decal d = a.getTexture();
|
||||
|
@ -163,7 +163,7 @@ public class GeneralRocketSaver {
|
||||
Appearance ap = c.getAppearance();
|
||||
Appearance ap_in = null;
|
||||
if (c instanceof InsideColorComponent)
|
||||
ap_in = ((InsideColorComponent)c).getInsideAppearance();
|
||||
ap_in = ((InsideColorComponent)c).getInsideColorComponentHandler().getInsideAppearance();
|
||||
|
||||
if ((ap == null) && (ap_in == null)) continue;
|
||||
if (ap != null) {
|
||||
|
@ -24,13 +24,13 @@ public class InsideAppearanceHandler extends AppearanceHandler {
|
||||
if ("edgesSameAsInside".equals(element)) {
|
||||
boolean edgesSameAsInside = Boolean.parseBoolean(content);
|
||||
if (component instanceof InsideColorComponent)
|
||||
((InsideColorComponent)component).setEdgesSameAsInside(edgesSameAsInside);
|
||||
((InsideColorComponent)component).getInsideColorComponentHandler().setEdgesSameAsInside(edgesSameAsInside);
|
||||
return;
|
||||
}
|
||||
if ("insideSameAsOutside".equals(element)) {
|
||||
boolean insideSameAsOutside = Boolean.parseBoolean(content);
|
||||
if (component instanceof InsideColorComponent)
|
||||
((InsideColorComponent)component).setInsideSameAsOutside(insideSameAsOutside);
|
||||
((InsideColorComponent)component).getInsideColorComponentHandler().setInsideSameAsOutside(insideSameAsOutside);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -40,6 +40,6 @@ public class InsideAppearanceHandler extends AppearanceHandler {
|
||||
@Override
|
||||
protected void setAppearance() {
|
||||
if ((component instanceof InsideColorComponent))
|
||||
((InsideColorComponent)component).setInsideAppearance(builder.getAppearance());
|
||||
((InsideColorComponent)component).getInsideColorComponentHandler().setInsideAppearance(builder.getAppearance());
|
||||
}
|
||||
}
|
||||
|
@ -53,11 +53,12 @@ public class RocketComponentSaver {
|
||||
|
||||
// Save inside appearance
|
||||
if (c instanceof InsideColorComponent) {
|
||||
Appearance ap_in = ((InsideColorComponent)c).getInsideAppearance();
|
||||
InsideColorComponentHandler handler = ((InsideColorComponent)c).getInsideColorComponentHandler();
|
||||
Appearance ap_in = handler.getInsideAppearance();
|
||||
if (ap_in != null) {
|
||||
elements.add("<inside-appearance>");
|
||||
elements.add("<edgesSameAsInside>" + ((InsideColorComponent) c).isEdgesSameAsInside() + "</edgesSameAsInside>");
|
||||
elements.add("<insideSameAsOutside>" + ((InsideColorComponent) c).isInsideSameAsOutside() + "</insideSameAsOutside>");
|
||||
elements.add("<edgesSameAsInside>" + handler.isEdgesSameAsInside() + "</edgesSameAsInside>");
|
||||
elements.add("<insideSameAsOutside>" + handler.isInsideSameAsOutside() + "</insideSameAsOutside>");
|
||||
buildAppearanceElements(elements, ap_in);
|
||||
elements.add("</inside-appearance>");
|
||||
}
|
||||
|
@ -32,10 +32,7 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou
|
||||
|
||||
private MotorConfigurationSet motors;
|
||||
|
||||
// Settings for inside/edge appearance
|
||||
private Appearance insideAppearance = null;
|
||||
private boolean insideSameAsOutside = true;
|
||||
private boolean edgesSameAsInside = true;
|
||||
private final InsideColorComponentHandler insideColorComponentHandler = new InsideColorComponentHandler(this);
|
||||
|
||||
public BodyTube() {
|
||||
this(8 * DEFAULT_RADIUS, DEFAULT_RADIUS);
|
||||
@ -459,48 +456,9 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou
|
||||
return ClusterConfiguration.SINGLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Appearance getInsideAppearance() {
|
||||
return this.insideAppearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideAppearance(Appearance appearance) {
|
||||
this.insideAppearance = appearance;
|
||||
if (this.insideAppearance != null) {
|
||||
Decal d = this.insideAppearance.getTexture();
|
||||
if (d != null) {
|
||||
d.getImage().addChangeListener(new StateChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(EventObject e) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
// CHECK - should this be a TEXTURE_CHANGE and not NONFUNCTIONAL_CHANGE?
|
||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEdgesSameAsInside() {
|
||||
return this.edgesSameAsInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEdgesSameAsInside(boolean newState) {
|
||||
this.edgesSameAsInside = newState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideSameAsOutside() {
|
||||
return this.insideSameAsOutside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideSameAsOutside(boolean newState) {
|
||||
this.insideSameAsOutside = newState;
|
||||
public InsideColorComponentHandler getInsideColorComponentHandler() {
|
||||
return this.insideColorComponentHandler;
|
||||
}
|
||||
}
|
||||
|
@ -19,50 +19,7 @@ import java.util.EventObject;
|
||||
*/
|
||||
public interface InsideColorComponent {
|
||||
/**
|
||||
* Get the realistic inside appearance of this component.
|
||||
* <code>null</code> = use the default for this material
|
||||
*
|
||||
* @return The component's realistic inner appearance, or <code>null</code>
|
||||
* @return the InsideColorComponentHandler
|
||||
*/
|
||||
Appearance getInsideAppearance();
|
||||
|
||||
/**
|
||||
* Set the realistic inside appearance of this component.
|
||||
* Use <code>null</code> for default.
|
||||
*
|
||||
* @param appearance the inner appearance to be set
|
||||
*/
|
||||
void setInsideAppearance(Appearance appearance);
|
||||
|
||||
/**
|
||||
* Checks whether the component uses for the edges the same appearance as the inside (return true) or as the
|
||||
* outside (return false)
|
||||
*
|
||||
* @return true if edges should use the same appearance as the inside,
|
||||
* false if edges should use the same appearance as the outside
|
||||
*/
|
||||
boolean isEdgesSameAsInside();
|
||||
|
||||
/**
|
||||
* Sets the new state for edgesUseInsideAppearance to newState
|
||||
*
|
||||
* @param newState new edgesUseInsideAppearance value
|
||||
*/
|
||||
void setEdgesSameAsInside(boolean newState);
|
||||
|
||||
/**
|
||||
* Checks whether the component should use the same appearance for the inside as the outside (return true) or as the
|
||||
* outside (return false)
|
||||
*
|
||||
* @return true if edges should use the same appearance as the inside,
|
||||
* false if edges should use the same appearance as the outside
|
||||
*/
|
||||
boolean isInsideSameAsOutside();
|
||||
|
||||
/**
|
||||
* Sets the new state for insideSameAsOutside to newState
|
||||
*
|
||||
* @param newState new edgesUseInsideAppearance value
|
||||
*/
|
||||
void setInsideSameAsOutside(boolean newState);
|
||||
InsideColorComponentHandler getInsideColorComponentHandler();
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
import net.sf.openrocket.appearance.Appearance;
|
||||
import net.sf.openrocket.appearance.Decal;
|
||||
import net.sf.openrocket.util.StateChangeListener;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* This component handles the necessary functionalities of an InsideColorComponent.
|
||||
*
|
||||
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
||||
*/
|
||||
public class InsideColorComponentHandler {
|
||||
private final RocketComponent component;
|
||||
private Appearance insideAppearance = null;
|
||||
private boolean insideSameAsOutside = true;
|
||||
private boolean edgesSameAsInside = true;
|
||||
|
||||
public InsideColorComponentHandler(RocketComponent component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the realistic inside appearance of this component.
|
||||
* <code>null</code> = use the default for this material
|
||||
*
|
||||
* @return The component's realistic inner appearance, or <code>null</code>
|
||||
*/
|
||||
public Appearance getInsideAppearance() {
|
||||
return this.insideAppearance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the realistic inside appearance of this component.
|
||||
* Use <code>null</code> for default.
|
||||
*
|
||||
* @param appearance the inner appearance to be set
|
||||
*/
|
||||
public void setInsideAppearance(Appearance appearance) {
|
||||
this.insideAppearance = appearance;
|
||||
if (this.insideAppearance != null) {
|
||||
Decal d = this.insideAppearance.getTexture();
|
||||
if (d != null) {
|
||||
d.getImage().addChangeListener(new StateChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(EventObject e) {
|
||||
component.fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
component.fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the component uses for the edges the same appearance as the inside (return true) or as the
|
||||
* outside (return false)
|
||||
*
|
||||
* @return true if edges should use the same appearance as the inside,
|
||||
* false if edges should use the same appearance as the outside
|
||||
*/
|
||||
public boolean isEdgesSameAsInside() {
|
||||
return this.edgesSameAsInside;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new state for edgesUseInsideAppearance to newState
|
||||
*
|
||||
* @param newState new edgesUseInsideAppearance value
|
||||
*/
|
||||
public void setEdgesSameAsInside(boolean newState) {
|
||||
this.edgesSameAsInside = newState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the component should use the same appearance for the inside as the outside (return true) or as the
|
||||
* outside (return false)
|
||||
*
|
||||
* @return true if edges should use the same appearance as the inside,
|
||||
* false if edges should use the same appearance as the outside
|
||||
*/
|
||||
public boolean isInsideSameAsOutside() {
|
||||
return this.insideSameAsOutside;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new state for insideSameAsOutside to newState
|
||||
*
|
||||
* @param newState new edgesUseInsideAppearance value
|
||||
*/
|
||||
public void setInsideSameAsOutside(boolean newState) {
|
||||
this.insideSameAsOutside = newState;
|
||||
}
|
||||
}
|
@ -30,10 +30,7 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
||||
private int instanceCount = 1;
|
||||
private double instanceSeparation = 0; // front-front along the positive rocket axis. i.e. [1,0,0];
|
||||
|
||||
// Settings for inside/edge appearance
|
||||
private Appearance insideAppearance = null;
|
||||
private boolean insideSameAsOutside = true;
|
||||
private boolean edgesSameAsInside = true;
|
||||
private final InsideColorComponentHandler insideColorComponentHandler = new InsideColorComponentHandler(this);
|
||||
|
||||
public LaunchLug() {
|
||||
super(AxialMethod.MIDDLE);
|
||||
@ -289,47 +286,7 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
||||
}
|
||||
|
||||
@Override
|
||||
public Appearance getInsideAppearance() {
|
||||
return this.insideAppearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideAppearance(Appearance appearance) {
|
||||
this.insideAppearance = appearance;
|
||||
if (this.insideAppearance != null) {
|
||||
Decal d = this.insideAppearance.getTexture();
|
||||
if (d != null) {
|
||||
d.getImage().addChangeListener(new StateChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(EventObject e) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
// CHECK - should this be a TEXTURE_CHANGE and not NONFUNCTIONAL_CHANGE?
|
||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEdgesSameAsInside() {
|
||||
return this.edgesSameAsInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEdgesSameAsInside(boolean newState) {
|
||||
this.edgesSameAsInside = newState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideSameAsOutside() {
|
||||
return this.insideSameAsOutside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideSameAsOutside(boolean newState) {
|
||||
this.insideSameAsOutside = newState;
|
||||
public InsideColorComponentHandler getInsideColorComponentHandler() {
|
||||
return this.insideColorComponentHandler;
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,7 @@ import java.util.EventObject;
|
||||
public class NoseCone extends Transition implements InsideColorComponent {
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
// Settings for inside/edge appearance
|
||||
private Appearance insideAppearance = null;
|
||||
private boolean insideSameAsOutside = true;
|
||||
private boolean edgesSameAsInside = true;
|
||||
private final InsideColorComponentHandler insideColorComponentHandler = new InsideColorComponentHandler(this);
|
||||
|
||||
/********* Constructors **********/
|
||||
public NoseCone() {
|
||||
@ -145,48 +142,9 @@ public class NoseCone extends Transition implements InsideColorComponent {
|
||||
return trans.get("NoseCone.NoseCone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Appearance getInsideAppearance() {
|
||||
return this.insideAppearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideAppearance(Appearance appearance) {
|
||||
this.insideAppearance = appearance;
|
||||
if (this.insideAppearance != null) {
|
||||
Decal d = this.insideAppearance.getTexture();
|
||||
if (d != null) {
|
||||
d.getImage().addChangeListener(new StateChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(EventObject e) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
// CHECK - should this be a TEXTURE_CHANGE and not NONFUNCTIONAL_CHANGE?
|
||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEdgesSameAsInside() {
|
||||
return this.edgesSameAsInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEdgesSameAsInside(boolean newState) {
|
||||
this.edgesSameAsInside = newState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideSameAsOutside() {
|
||||
return this.insideSameAsOutside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideSameAsOutside(boolean newState) {
|
||||
this.insideSameAsOutside = newState;
|
||||
public InsideColorComponentHandler getInsideColorComponentHandler() {
|
||||
return this.insideColorComponentHandler;
|
||||
}
|
||||
}
|
||||
|
@ -44,10 +44,7 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
||||
// Used to cache the clip length
|
||||
private double clipLength = -1;
|
||||
|
||||
// Settings for inside/edge appearance
|
||||
private Appearance insideAppearance = null;
|
||||
private boolean insideSameAsOutside = true;
|
||||
private boolean edgesSameAsInside = true;
|
||||
private final InsideColorComponentHandler insideColorComponentHandler = new InsideColorComponentHandler(this);
|
||||
|
||||
public Transition() {
|
||||
super();
|
||||
@ -607,6 +604,11 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public InsideColorComponentHandler getInsideColorComponentHandler() {
|
||||
return this.insideColorComponentHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration listing the possible shapes of transitions.
|
||||
*
|
||||
@ -947,48 +949,5 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Appearance getInsideAppearance() {
|
||||
return this.insideAppearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideAppearance(Appearance appearance) {
|
||||
this.insideAppearance = appearance;
|
||||
if (this.insideAppearance != null) {
|
||||
Decal d = this.insideAppearance.getTexture();
|
||||
if (d != null) {
|
||||
d.getImage().addChangeListener(new StateChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(EventObject e) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
// CHECK - should this be a TEXTURE_CHANGE and not NONFUNCTIONAL_CHANGE?
|
||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEdgesSameAsInside() {
|
||||
return this.edgesSameAsInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEdgesSameAsInside(boolean newState) {
|
||||
this.edgesSameAsInside = newState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideSameAsOutside() {
|
||||
return this.insideSameAsOutside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideSameAsOutside(boolean newState) {
|
||||
this.insideSameAsOutside = newState;
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,7 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable,
|
||||
private AngleMethod angleMethod = AngleMethod.FIXED;
|
||||
protected RadiusMethod radiusMethod = RadiusMethod.RELATIVE;
|
||||
|
||||
// Settings for inside/edge appearance
|
||||
private Appearance insideAppearance = null;
|
||||
private boolean insideSameAsOutside = true;
|
||||
private boolean edgesSameAsInside = true;
|
||||
private final InsideColorComponentHandler insideColorComponentHandler = new InsideColorComponentHandler(this);
|
||||
|
||||
/**
|
||||
* Rotation angle of the first fin. Zero corresponds to the positive y-axis.
|
||||
@ -458,49 +455,9 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable,
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Appearance getInsideAppearance() {
|
||||
return this.insideAppearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideAppearance(Appearance appearance) {
|
||||
this.insideAppearance = appearance;
|
||||
if (this.insideAppearance != null) {
|
||||
Decal d = this.insideAppearance.getTexture();
|
||||
if (d != null) {
|
||||
d.getImage().addChangeListener(new StateChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(EventObject e) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
// CHECK - should this be a TEXTURE_CHANGE and not NONFUNCTIONAL_CHANGE?
|
||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
public InsideColorComponentHandler getInsideColorComponentHandler() {
|
||||
return this.insideColorComponentHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEdgesSameAsInside() {
|
||||
return this.edgesSameAsInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEdgesSameAsInside(boolean newState) {
|
||||
this.edgesSameAsInside = newState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideSameAsOutside() {
|
||||
return this.insideSameAsOutside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideSameAsOutside(boolean newState) {
|
||||
this.insideSameAsOutside = newState;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import net.sf.openrocket.gui.util.SwingPreferences;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||
import net.sf.openrocket.rocketcomponent.InsideColorComponent;
|
||||
import net.sf.openrocket.rocketcomponent.InsideColorComponentHandler;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.unit.GeneralUnit;
|
||||
@ -187,7 +188,8 @@ public class AppearancePanel extends JPanel {
|
||||
}
|
||||
|
||||
if (c instanceof InsideColorComponent) {
|
||||
previousUserSelectedInsideAppearance = ((InsideColorComponent) c).getInsideAppearance();
|
||||
previousUserSelectedInsideAppearance = ((InsideColorComponent) c).getInsideColorComponentHandler()
|
||||
.getInsideAppearance();
|
||||
if (previousUserSelectedInsideAppearance == null) {
|
||||
previousUserSelectedInsideAppearance = new AppearanceBuilder()
|
||||
.getAppearance();
|
||||
@ -298,6 +300,8 @@ public class AppearancePanel extends JPanel {
|
||||
|
||||
// Display a tabbed panel for choosing the outside and inside appearance, if the object is of type InsideColorComponent
|
||||
if (c instanceof InsideColorComponent) {
|
||||
InsideColorComponentHandler handler = ((InsideColorComponent)c).getInsideColorComponentHandler();
|
||||
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
JPanel outsidePanel = new JPanel(new MigLayout("fill", "[150][grow][150][grow]"));
|
||||
JPanel insidePanel = new JPanel(new MigLayout("fill", "[150][grow][150][grow]"));
|
||||
@ -312,7 +316,7 @@ public class AppearancePanel extends JPanel {
|
||||
add(tabbedPane, "span 4, growx, wrap");
|
||||
|
||||
// Checkbox to set edges the same as inside/outside
|
||||
BooleanModel b = new BooleanModel(((InsideColorComponent) c).isEdgesSameAsInside());
|
||||
BooleanModel b = new BooleanModel(handler.isEdgesSameAsInside());
|
||||
JCheckBox edges = new JCheckBox(b);
|
||||
edges.setText(trans.get("AppearanceCfg.lbl.EdgesSameAsInside"));
|
||||
edges.setToolTipText(trans.get("AppearanceCfg.lbl.ttip.EdgesSameAsInside"));
|
||||
@ -321,7 +325,7 @@ public class AppearancePanel extends JPanel {
|
||||
edges.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
((InsideColorComponent) c).setEdgesSameAsInside(edges.isSelected());
|
||||
handler.setEdgesSameAsInside(edges.isSelected());
|
||||
c.fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
});
|
||||
@ -347,7 +351,8 @@ public class AppearancePanel extends JPanel {
|
||||
}
|
||||
else if (c instanceof InsideColorComponent) {
|
||||
builder = insideAb;
|
||||
mDefault = new BooleanModel(((InsideColorComponent)c).getInsideAppearance() == null);
|
||||
mDefault = new BooleanModel(
|
||||
((InsideColorComponent)c).getInsideColorComponentHandler().getInsideAppearance() == null);
|
||||
}
|
||||
else return;
|
||||
|
||||
@ -363,7 +368,7 @@ public class AppearancePanel extends JPanel {
|
||||
if (!insideBuilder)
|
||||
c.setAppearance(builder.getAppearance());
|
||||
else
|
||||
((InsideColorComponent)c).setInsideAppearance(builder.getAppearance());
|
||||
((InsideColorComponent)c).getInsideColorComponentHandler().setInsideAppearance(builder.getAppearance());
|
||||
decalModel.refresh();
|
||||
}
|
||||
});
|
||||
@ -403,14 +408,15 @@ public class AppearancePanel extends JPanel {
|
||||
|
||||
// Custom inside color
|
||||
if (insideBuilder) {
|
||||
BooleanModel b = new BooleanModel(((InsideColorComponent) c).isInsideSameAsOutside());
|
||||
InsideColorComponentHandler handler = ((InsideColorComponent)c).getInsideColorComponentHandler();
|
||||
BooleanModel b = new BooleanModel(handler.isInsideSameAsOutside());
|
||||
JCheckBox customInside = new JCheckBox(b);
|
||||
customInside.setText(trans.get("AppearanceCfg.lbl.InsideSameAsOutside"));
|
||||
customInside.setToolTipText(trans.get("AppearanceCfg.lbl.ttip.InsideSameAsOutside"));
|
||||
customInside.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
((InsideColorComponent) c).setInsideSameAsOutside(customInside.isSelected());
|
||||
handler.setInsideSameAsOutside(customInside.isSelected());
|
||||
c.fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
});
|
||||
|
@ -95,10 +95,10 @@ public class RealisticRenderer extends RocketRenderer {
|
||||
Appearance app = getAppearance(c);
|
||||
if (c instanceof InsideColorComponent) {
|
||||
Appearance innerApp = getInsideAppearance(c);
|
||||
if (((InsideColorComponent) c).isInsideSameAsOutside()) innerApp = app;
|
||||
if (((InsideColorComponent) c).getInsideColorComponentHandler().isInsideSameAsOutside()) innerApp = app;
|
||||
|
||||
render(gl, geom, Surface.INSIDE, innerApp, true, alpha);
|
||||
if (((InsideColorComponent) c).isEdgesSameAsInside())
|
||||
if (((InsideColorComponent) c).getInsideColorComponentHandler().isEdgesSameAsInside())
|
||||
render(gl, geom, Surface.EDGES, innerApp, false, alpha);
|
||||
else
|
||||
render(gl, geom, Surface.EDGES, app, false, alpha);
|
||||
@ -208,7 +208,7 @@ public class RealisticRenderer extends RocketRenderer {
|
||||
|
||||
protected Appearance getInsideAppearance(RocketComponent c) {
|
||||
if (c instanceof InsideColorComponent) {
|
||||
Appearance ret = ((InsideColorComponent)c).getInsideAppearance();
|
||||
Appearance ret = ((InsideColorComponent)c).getInsideColorComponentHandler().getInsideAppearance();
|
||||
if (ret == null) {
|
||||
ret = DefaultAppearance.getDefaultAppearance(c);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import net.sf.openrocket.gui.watcher.WatchEvent;
|
||||
import net.sf.openrocket.gui.watcher.WatchService;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.rocketcomponent.InsideColorComponent;
|
||||
import net.sf.openrocket.rocketcomponent.InsideColorComponentHandler;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
@ -143,11 +144,11 @@ public class EditDecalHelper {
|
||||
DecalImage newImage = doc.makeUniqueDecal(decal);
|
||||
|
||||
if (component instanceof InsideColorComponent) {
|
||||
InsideColorComponent c = ((InsideColorComponent)component);
|
||||
AppearanceBuilder appearanceBuilder = new AppearanceBuilder(c.getInsideAppearance());
|
||||
InsideColorComponentHandler handler = ((InsideColorComponent)component).getInsideColorComponentHandler();
|
||||
AppearanceBuilder appearanceBuilder = new AppearanceBuilder(handler.getInsideAppearance());
|
||||
appearanceBuilder.setImage(newImage);
|
||||
|
||||
c.setInsideAppearance(appearanceBuilder.getAppearance());
|
||||
handler.setInsideAppearance(appearanceBuilder.getAppearance());
|
||||
}
|
||||
|
||||
return newImage;
|
||||
|
Loading…
x
Reference in New Issue
Block a user