Merge pull request #2511 from AhanuDewhirst/issue-2485
[#2485] Hide components
This commit is contained in:
commit
aa64eedad2
@ -147,6 +147,12 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
// If true, component change events will not be fired
|
// If true, component change events will not be fired
|
||||||
private boolean bypassComponentChangeEvent = false;
|
private boolean bypassComponentChangeEvent = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls the visibility of the component. If false, the component will not be rendered.
|
||||||
|
* Visibility does not affect component simulation.
|
||||||
|
*/
|
||||||
|
private boolean isVisible = true;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to invalidate the component after calling {@link #copyFrom(RocketComponent)}.
|
* Used to invalidate the component after calling {@link #copyFrom(RocketComponent)}.
|
||||||
@ -2707,6 +2713,24 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this component is visible.
|
||||||
|
* @return True if this component is visible.
|
||||||
|
* @apiNote The component is rendered if true is returned.
|
||||||
|
*/
|
||||||
|
public boolean isVisible() {
|
||||||
|
return isVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the component's visibility to the specified value.
|
||||||
|
* @param value Visibility value
|
||||||
|
* @apiNote The component is rendered if the specified value is set to true.
|
||||||
|
*/
|
||||||
|
public void setVisible(boolean value) {
|
||||||
|
this.isVisible = value;
|
||||||
|
fireComponentChangeEvent(ComponentChangeEvent.GRAPHIC_CHANGE);
|
||||||
|
}
|
||||||
|
|
||||||
/////////// Iterators //////////
|
/////////// Iterators //////////
|
||||||
|
|
||||||
|
@ -50,6 +50,16 @@ RocketActions.MoveDownAct.ttip.Movedown = Move this component downwards.
|
|||||||
RocketActions.ExportOBJAct.ExportOBJ = Export as OBJ (.obj)
|
RocketActions.ExportOBJAct.ExportOBJ = Export as OBJ (.obj)
|
||||||
RocketActions.ExportOBJAct.ttip.ExportOBJ = Export the selected components as a Wavefront OBJ 3D file.
|
RocketActions.ExportOBJAct.ttip.ExportOBJ = Export the selected components as a Wavefront OBJ 3D file.
|
||||||
|
|
||||||
|
RocketActions.Visibility = Visibility
|
||||||
|
RocketActions.VisibilityAct.ShowAll = Show all
|
||||||
|
RocketActions.VisibilityAct.ttip.ShowAll = Show all components.
|
||||||
|
RocketActions.VisibilityAct.HideAll = Hide all
|
||||||
|
RocketActions.VisibilityAct.ttip.HideAll = Hide all components.
|
||||||
|
RocketActions.VisibilityAct.ShowSelected = Show selected
|
||||||
|
RocketActions.VisibilityAct.ttip.ShowSelected = Show selected components.
|
||||||
|
RocketActions.VisibilityAct.HideSelected = Hide selected
|
||||||
|
RocketActions.VisibilityAct.ttip.HideSelected = Hide selected components.
|
||||||
|
|
||||||
! RocketPanel
|
! RocketPanel
|
||||||
RocketPanel.FigTypeAct.SideView = Side view
|
RocketPanel.FigTypeAct.SideView = Side view
|
||||||
RocketPanel.FigTypeAct.TopView = Top view
|
RocketPanel.FigTypeAct.TopView = Top view
|
||||||
|
@ -215,6 +215,9 @@ public abstract class RocketRenderer {
|
|||||||
throw new NullPointerException(" null motor from configuration.getActiveMotors... this is a bug.");
|
throw new NullPointerException(" null motor from configuration.getActiveMotors... this is a bug.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!((RocketComponent) mount).isVisible()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
double length = motor.getLength();
|
double length = motor.getLength();
|
||||||
|
|
||||||
Coordinate[] position = ((RocketComponent) mount).toAbsolute(new Coordinate(((RocketComponent) mount)
|
Coordinate[] position = ((RocketComponent) mount).toAbsolute(new Coordinate(((RocketComponent) mount)
|
||||||
|
@ -95,6 +95,9 @@ public class ComponentRenderer {
|
|||||||
if (glu == null)
|
if (glu == null)
|
||||||
throw new IllegalStateException(this + " Not Initialized");
|
throw new IllegalStateException(this + " Not Initialized");
|
||||||
|
|
||||||
|
if (!c.isVisible()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
glu.gluQuadricNormals(q, GLU.GLU_SMOOTH);
|
glu.gluQuadricNormals(q, GLU.GLU_SMOOTH);
|
||||||
|
|
||||||
if (c instanceof BodyTube) {
|
if (c instanceof BodyTube) {
|
||||||
|
@ -52,8 +52,6 @@ import net.miginfocom.swing.MigLayout;
|
|||||||
|
|
||||||
import info.openrocket.core.file.wavefrontobj.export.OBJExportOptions;
|
import info.openrocket.core.file.wavefrontobj.export.OBJExportOptions;
|
||||||
import info.openrocket.core.file.wavefrontobj.export.OBJExporterFactory;
|
import info.openrocket.core.file.wavefrontobj.export.OBJExporterFactory;
|
||||||
import info.openrocket.core.file.wavefrontobj.CoordTransform;
|
|
||||||
import info.openrocket.core.file.wavefrontobj.DefaultCoordTransform;
|
|
||||||
import info.openrocket.core.logging.ErrorSet;
|
import info.openrocket.core.logging.ErrorSet;
|
||||||
import info.openrocket.core.logging.WarningSet;
|
import info.openrocket.core.logging.WarningSet;
|
||||||
import info.openrocket.core.appearance.DecalImage;
|
import info.openrocket.core.appearance.DecalImage;
|
||||||
@ -257,6 +255,7 @@ public class BasicFrame extends JFrame {
|
|||||||
|
|
||||||
popupMenu.addSeparator();
|
popupMenu.addSeparator();
|
||||||
popupMenu.add(actions.getScaleAction());
|
popupMenu.add(actions.getScaleAction());
|
||||||
|
popupMenu.add(actions.getToggleVisibilityAction());
|
||||||
|
|
||||||
popupMenu.addSeparator();
|
popupMenu.addSeparator();
|
||||||
popupMenu.add(actions.getExportOBJAction());
|
popupMenu.add(actions.getExportOBJAction());
|
||||||
@ -608,6 +607,15 @@ public class BasicFrame extends JFrame {
|
|||||||
item = new JMenuItem(actions.getScaleAction());
|
item = new JMenuItem(actions.getScaleAction());
|
||||||
editMenu.add(item);
|
editMenu.add(item);
|
||||||
|
|
||||||
|
//// Visibility
|
||||||
|
JMenu visibilitySubMenu = new JMenu(trans.get("RocketActions.Visibility"));
|
||||||
|
editMenu.add(visibilitySubMenu);
|
||||||
|
item = new JMenuItem(actions.getToggleVisibilityAction());
|
||||||
|
visibilitySubMenu.add(item);
|
||||||
|
item = new JMenuItem(actions.getShowAllComponentsAction());
|
||||||
|
visibilitySubMenu.add(item);
|
||||||
|
|
||||||
|
editMenu.addSeparator();
|
||||||
|
|
||||||
//// Preferences
|
//// Preferences
|
||||||
item = new JMenuItem(trans.get("main.menu.edit.preferences"));
|
item = new JMenuItem(trans.get("main.menu.edit.preferences"));
|
||||||
|
@ -5,11 +5,7 @@ import java.awt.Toolkit;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
@ -18,8 +14,11 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
|
import info.openrocket.core.rocketcomponent.*;
|
||||||
import info.openrocket.swing.gui.configdialog.ComponentConfigDialog;
|
import info.openrocket.swing.gui.configdialog.ComponentConfigDialog;
|
||||||
import info.openrocket.swing.gui.dialogs.ScaleDialog;
|
import info.openrocket.swing.gui.dialogs.ScaleDialog;
|
||||||
|
import info.openrocket.swing.gui.util.GUIUtil;
|
||||||
import info.openrocket.swing.gui.util.Icons;
|
import info.openrocket.swing.gui.util.Icons;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -31,12 +30,6 @@ import info.openrocket.core.document.OpenRocketDocument;
|
|||||||
import info.openrocket.core.document.Simulation;
|
import info.openrocket.core.document.Simulation;
|
||||||
import info.openrocket.core.l10n.Translator;
|
import info.openrocket.core.l10n.Translator;
|
||||||
import info.openrocket.core.logging.Markers;
|
import info.openrocket.core.logging.Markers;
|
||||||
import info.openrocket.core.rocketcomponent.ComponentChangeEvent;
|
|
||||||
import info.openrocket.core.rocketcomponent.ComponentChangeListener;
|
|
||||||
import info.openrocket.core.rocketcomponent.ParallelStage;
|
|
||||||
import info.openrocket.core.rocketcomponent.Rocket;
|
|
||||||
import info.openrocket.core.rocketcomponent.RocketComponent;
|
|
||||||
import info.openrocket.core.rocketcomponent.AxialStage;
|
|
||||||
import info.openrocket.core.startup.Application;
|
import info.openrocket.core.startup.Application;
|
||||||
import info.openrocket.core.util.ORColor;
|
import info.openrocket.core.util.ORColor;
|
||||||
import info.openrocket.core.util.Pair;
|
import info.openrocket.core.util.Pair;
|
||||||
@ -81,6 +74,8 @@ public class RocketActions {
|
|||||||
private final RocketAction moveUpAction;
|
private final RocketAction moveUpAction;
|
||||||
private final RocketAction moveDownAction;
|
private final RocketAction moveDownAction;
|
||||||
private final RocketAction exportOBJAction;
|
private final RocketAction exportOBJAction;
|
||||||
|
private final RocketAction toggleVisibilityAction;
|
||||||
|
private final RocketAction showAllComponentsAction;
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final Logger log = LoggerFactory.getLogger(RocketActions.class);
|
private static final Logger log = LoggerFactory.getLogger(RocketActions.class);
|
||||||
|
|
||||||
@ -106,6 +101,8 @@ public class RocketActions {
|
|||||||
this.moveUpAction = new MoveUpAction();
|
this.moveUpAction = new MoveUpAction();
|
||||||
this.moveDownAction = new MoveDownAction();
|
this.moveDownAction = new MoveDownAction();
|
||||||
this.exportOBJAction = new ExportOBJAction();
|
this.exportOBJAction = new ExportOBJAction();
|
||||||
|
this.toggleVisibilityAction = new ToggleVisibilityAction();
|
||||||
|
this.showAllComponentsAction = new ShowAllComponentsAction();
|
||||||
|
|
||||||
OpenRocketClipboard.addClipboardListener(new ClipboardListener() {
|
OpenRocketClipboard.addClipboardListener(new ClipboardListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -154,6 +151,8 @@ public class RocketActions {
|
|||||||
moveUpAction.clipboardChanged();
|
moveUpAction.clipboardChanged();
|
||||||
moveDownAction.clipboardChanged();
|
moveDownAction.clipboardChanged();
|
||||||
exportOBJAction.clipboardChanged();
|
exportOBJAction.clipboardChanged();
|
||||||
|
toggleVisibilityAction.clipboardChanged();
|
||||||
|
showAllComponentsAction.clipboardChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -207,6 +206,14 @@ public class RocketActions {
|
|||||||
return exportOBJAction;
|
return exportOBJAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action getToggleVisibilityAction() {
|
||||||
|
return toggleVisibilityAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action getShowAllComponentsAction() {
|
||||||
|
return showAllComponentsAction;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tie an action to a JButton, without using the icon or text of the action for the button.
|
* Tie an action to a JButton, without using the icon or text of the action for the button.
|
||||||
*
|
*
|
||||||
@ -482,7 +489,26 @@ public class RocketActions {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all descendants of the specified component.
|
||||||
|
*
|
||||||
|
* @param component Component to query
|
||||||
|
* @return All descendants
|
||||||
|
* @apiNote Returns an empty set if the component does not have children.
|
||||||
|
*/
|
||||||
|
private Set<RocketComponent> getDescendants(RocketComponent component) {
|
||||||
|
Objects.requireNonNull(component);
|
||||||
|
|
||||||
|
var result = new LinkedHashSet<RocketComponent>();
|
||||||
|
var queue = new ArrayDeque<>(component.getChildren());
|
||||||
|
|
||||||
|
while (!queue.isEmpty()) {
|
||||||
|
var node = queue.pop();
|
||||||
|
result.add(node);
|
||||||
|
node.getChildren().stream().filter(c -> !result.contains(c)).forEach(queue::add);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////// Action classes
|
/////// Action classes
|
||||||
@ -1257,4 +1283,121 @@ public class RocketActions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to toggle the visibility of the selected components.
|
||||||
|
* @see RocketComponent#isVisible()
|
||||||
|
*/
|
||||||
|
private class ToggleVisibilityAction extends RocketAction {
|
||||||
|
public ToggleVisibilityAction() {
|
||||||
|
super.putValue(NAME, trans.get("RocketActions.VisibilityAct.HideSelected"));
|
||||||
|
super.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.VisibilityAct.ttip.HideSelected"));
|
||||||
|
super.putValue(SMALL_ICON, GUIUtil.getUITheme().getVisibilityHiddenIcon());
|
||||||
|
clipboardChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clipboardChanged() {
|
||||||
|
var components = new ArrayList<>(selectionModel.getSelectedComponents());
|
||||||
|
super.setEnabled(!components.isEmpty());
|
||||||
|
|
||||||
|
if (components.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRocketSelected(components)) {
|
||||||
|
super.putValue(NAME, rocket.isVisible() ?
|
||||||
|
trans.get("RocketActions.VisibilityAct.HideAll") :
|
||||||
|
trans.get("RocketActions.VisibilityAct.ShowAll"));
|
||||||
|
super.putValue(SHORT_DESCRIPTION, rocket.isVisible() ?
|
||||||
|
trans.get("RocketActions.VisibilityAct.ttip.HideAll") :
|
||||||
|
trans.get("RocketActions.VisibilityAct.ttip.ShowAll"));
|
||||||
|
super.putValue(SMALL_ICON, rocket.isVisible() ?
|
||||||
|
GUIUtil.getUITheme().getVisibilityHiddenIcon() :
|
||||||
|
GUIUtil.getUITheme().getVisibilityShowingIcon());
|
||||||
|
} else {
|
||||||
|
var visibility = components.stream().anyMatch(RocketComponent::isVisible);
|
||||||
|
super.putValue(NAME, visibility ?
|
||||||
|
trans.get("RocketActions.VisibilityAct.HideSelected") :
|
||||||
|
trans.get("RocketActions.VisibilityAct.ShowSelected"));
|
||||||
|
super.putValue(SHORT_DESCRIPTION, visibility ?
|
||||||
|
trans.get("RocketActions.VisibilityAct.ttip.HideSelected") :
|
||||||
|
trans.get("RocketActions.VisibilityAct.ttip.ShowSelected"));
|
||||||
|
super.putValue(SMALL_ICON, visibility ?
|
||||||
|
GUIUtil.getUITheme().getVisibilityHiddenIcon() :
|
||||||
|
GUIUtil.getUITheme().getVisibilityShowingIcon());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
var components = new ArrayList<>(selectionModel.getSelectedComponents());
|
||||||
|
|
||||||
|
if (components.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle the visibility of the rocket and its descendants
|
||||||
|
if (isRocketSelected(components)) {
|
||||||
|
var rocketVisibility = !rocket.isVisible();
|
||||||
|
rocket.setVisible(rocketVisibility);
|
||||||
|
getDescendants(rocket).forEach(descendant -> descendant.setVisible(rocketVisibility));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var visibility = components.stream().noneMatch(RocketComponent::isVisible);
|
||||||
|
|
||||||
|
// Toggle the visibility of all non-stage and non-rocket components
|
||||||
|
components.stream().filter(c -> !(c instanceof AxialStage || c instanceof Rocket)).forEach(component -> {
|
||||||
|
component.setVisible(visibility);
|
||||||
|
|
||||||
|
// Update the visibility of this component's stage
|
||||||
|
var stage = component.getStage();
|
||||||
|
stage.setVisible(getDescendants(stage).stream().anyMatch(RocketComponent::isVisible));
|
||||||
|
|
||||||
|
// Update the visibility of the rocket
|
||||||
|
rocket.setVisible(getDescendants(rocket).stream().anyMatch(RocketComponent::isVisible));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Toggle the visibility of all stage components and their descendants
|
||||||
|
components.stream().filter(AxialStage.class::isInstance).forEach(stage -> {
|
||||||
|
stage.setVisible(visibility);
|
||||||
|
getDescendants(stage).forEach(descendant -> descendant.setVisible(visibility));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the rocket or all descendant are in the specified list.
|
||||||
|
*
|
||||||
|
* @param components Components to query
|
||||||
|
* @return True if all components are selected
|
||||||
|
*/
|
||||||
|
private boolean isRocketSelected(List<RocketComponent> components) {
|
||||||
|
var rocketSelected = components.stream().anyMatch(Rocket.class::isInstance);
|
||||||
|
var allComponentsSelected = getDescendants(rocket).size() == components.size();
|
||||||
|
return rocketSelected || allComponentsSelected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to show all hidden components.
|
||||||
|
* @see RocketComponent#isVisible()
|
||||||
|
*/
|
||||||
|
private class ShowAllComponentsAction extends RocketAction {
|
||||||
|
public ShowAllComponentsAction() {
|
||||||
|
super.putValue(NAME, trans.get("RocketActions.VisibilityAct.ShowAll"));
|
||||||
|
super.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.VisibilityAct.ttip.ShowAll"));
|
||||||
|
super.putValue(SMALL_ICON, GUIUtil.getUITheme().getVisibilityShowingIcon());
|
||||||
|
clipboardChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clipboardChanged() {
|
||||||
|
super.setEnabled(getDescendants(rocket).stream().anyMatch(c -> !c.isVisible()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
rocket.setVisible(true);
|
||||||
|
getDescendants(rocket).forEach(descendant -> descendant.setVisible(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,23 +3,16 @@ package info.openrocket.swing.gui.main.componenttree;
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.Border;
|
|
||||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
@ -35,6 +28,7 @@ import info.openrocket.core.startup.Application;
|
|||||||
import info.openrocket.core.unit.UnitGroup;
|
import info.openrocket.core.unit.UnitGroup;
|
||||||
import info.openrocket.core.util.ArrayList;
|
import info.openrocket.core.util.ArrayList;
|
||||||
import info.openrocket.core.util.TextUtil;
|
import info.openrocket.core.util.TextUtil;
|
||||||
|
import info.openrocket.swing.gui.util.Icons;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
||||||
@ -45,6 +39,7 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
private static Color textSelectionForegroundColor;
|
private static Color textSelectionForegroundColor;
|
||||||
private static Color componentTreeBackgroundColor;
|
private static Color componentTreeBackgroundColor;
|
||||||
private static Color componentTreeForegroundColor;
|
private static Color componentTreeForegroundColor;
|
||||||
|
private static Color visibilityHiddenForegroundColor;
|
||||||
private static Icon massOverrideSubcomponentIcon;
|
private static Icon massOverrideSubcomponentIcon;
|
||||||
private static Icon massOverrideIcon;
|
private static Icon massOverrideIcon;
|
||||||
private static Icon CGOverrideSubcomponentIcon;
|
private static Icon CGOverrideSubcomponentIcon;
|
||||||
@ -92,6 +87,11 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
RocketComponent c = (RocketComponent) value;
|
RocketComponent c = (RocketComponent) value;
|
||||||
applyToolTipText(components, c, panel);
|
applyToolTipText(components, c, panel);
|
||||||
|
|
||||||
|
// Set the cell text color if component is hidden
|
||||||
|
if (!c.isVisible() && !sel) {
|
||||||
|
label.setForeground(visibilityHiddenForegroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
// Set the tree icon
|
// Set the tree icon
|
||||||
final Icon treeIcon;
|
final Icon treeIcon;
|
||||||
if (c.getClass().isAssignableFrom(MassComponent.class)) {
|
if (c.getClass().isAssignableFrom(MassComponent.class)) {
|
||||||
@ -103,10 +103,11 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
|
|
||||||
panel.add(new JLabel(treeIcon), BorderLayout.WEST);
|
panel.add(new JLabel(treeIcon), BorderLayout.WEST);
|
||||||
|
|
||||||
// Add mass/CG/CD overridden icons
|
// Add mass/CG/CD overridden and component hidden icons
|
||||||
if (c.isMassOverridden() || c.getMassOverriddenBy() != null ||
|
if (c.isMassOverridden() || c.getMassOverriddenBy() != null ||
|
||||||
c.isCGOverridden() || c.getCGOverriddenBy() != null ||
|
c.isCGOverridden() || c.getCGOverriddenBy() != null ||
|
||||||
c.isCDOverridden() || c.getCDOverriddenBy() != null) {
|
c.isCDOverridden() || c.getCDOverriddenBy() != null ||
|
||||||
|
!c.isVisible()) {
|
||||||
List<Icon> icons = new LinkedList<>();
|
List<Icon> icons = new LinkedList<>();
|
||||||
if (c.getMassOverriddenBy() != null) {
|
if (c.getMassOverriddenBy() != null) {
|
||||||
icons.add(massOverrideSubcomponentIcon);
|
icons.add(massOverrideSubcomponentIcon);
|
||||||
@ -123,6 +124,9 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
} else if (c.isCDOverridden()) {
|
} else if (c.isCDOverridden()) {
|
||||||
icons.add(CDOverrideIcon);
|
icons.add(CDOverrideIcon);
|
||||||
}
|
}
|
||||||
|
if (!c.isVisible()) {
|
||||||
|
icons.add(Icons.COMPONENT_HIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
Icon combinedIcon = combineIcons(3, icons.toArray(new Icon[0]));
|
Icon combinedIcon = combineIcons(3, icons.toArray(new Icon[0]));
|
||||||
JLabel overrideIconsLabel = new JLabel(combinedIcon);
|
JLabel overrideIconsLabel = new JLabel(combinedIcon);
|
||||||
@ -144,6 +148,7 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
CGOverrideIcon = GUIUtil.getUITheme().getCGOverrideIcon();
|
CGOverrideIcon = GUIUtil.getUITheme().getCGOverrideIcon();
|
||||||
CDOverrideSubcomponentIcon = GUIUtil.getUITheme().getCDOverrideSubcomponentIcon();
|
CDOverrideSubcomponentIcon = GUIUtil.getUITheme().getCDOverrideSubcomponentIcon();
|
||||||
CDOverrideIcon = GUIUtil.getUITheme().getCDOverrideIcon();
|
CDOverrideIcon = GUIUtil.getUITheme().getCDOverrideIcon();
|
||||||
|
visibilityHiddenForegroundColor = GUIUtil.getUITheme().getVisibilityHiddenForegroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyToolTipText(List<RocketComponent> components, RocketComponent c, JComponent comp) {
|
private void applyToolTipText(List<RocketComponent> components, RocketComponent c, JComponent comp) {
|
||||||
|
@ -265,6 +265,10 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
while (!figureShapesCopy.isEmpty()) {
|
while (!figureShapesCopy.isEmpty()) {
|
||||||
RocketComponentShapes rcs = figureShapesCopy.poll();
|
RocketComponentShapes rcs = figureShapesCopy.poll();
|
||||||
RocketComponent c = rcs.getComponent();
|
RocketComponent c = rcs.getComponent();
|
||||||
|
|
||||||
|
if (!c.isVisible()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
boolean selected = false;
|
boolean selected = false;
|
||||||
|
|
||||||
// Check if component is in the selection
|
// Check if component is in the selection
|
||||||
@ -322,6 +326,10 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
double motorRadius = motor.getDiameter() / 2;
|
double motorRadius = motor.getDiameter() / 2;
|
||||||
RocketComponent mountComponent = ((RocketComponent) mount);
|
RocketComponent mountComponent = ((RocketComponent) mount);
|
||||||
|
|
||||||
|
if (!mountComponent.isVisible()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// <component>.getLocation() will return all the parent instances of this owning component, AND all of it's own instances as well.
|
// <component>.getLocation() will return all the parent instances of this owning component, AND all of it's own instances as well.
|
||||||
// so, just draw a motor once for each Coordinate returned...
|
// so, just draw a motor once for each Coordinate returned...
|
||||||
Coordinate[] mountLocations = mount.getLocations();
|
Coordinate[] mountLocations = mount.getLocations();
|
||||||
|
@ -85,6 +85,7 @@ public class UITheme {
|
|||||||
|
|
||||||
Color getComponentTreeBackgroundColor();
|
Color getComponentTreeBackgroundColor();
|
||||||
Color getComponentTreeForegroundColor();
|
Color getComponentTreeForegroundColor();
|
||||||
|
Color getVisibilityHiddenForegroundColor();
|
||||||
|
|
||||||
Color getFinPointGridMajorLineColor();
|
Color getFinPointGridMajorLineColor();
|
||||||
Color getFinPointGridMinorLineColor();
|
Color getFinPointGridMinorLineColor();
|
||||||
@ -99,6 +100,9 @@ public class UITheme {
|
|||||||
Icon getCDOverrideIcon();
|
Icon getCDOverrideIcon();
|
||||||
Icon getCDOverrideSubcomponentIcon();
|
Icon getCDOverrideSubcomponentIcon();
|
||||||
|
|
||||||
|
Icon getVisibilityHiddenIcon();
|
||||||
|
Icon getVisibilityShowingIcon();
|
||||||
|
|
||||||
Border getBorder();
|
Border getBorder();
|
||||||
Border getMarginBorder();
|
Border getMarginBorder();
|
||||||
Border getUnitSelectorBorder();
|
Border getUnitSelectorBorder();
|
||||||
@ -369,6 +373,11 @@ public class UITheme {
|
|||||||
return UIManager.getColor("Tree.textForeground");
|
return UIManager.getColor("Tree.textForeground");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color getVisibilityHiddenForegroundColor() {
|
||||||
|
return UIManager.getColor("Tree.textForeground.hidden.light");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getFinPointGridMajorLineColor() {
|
public Color getFinPointGridMajorLineColor() {
|
||||||
return new Color( 0, 0, 255, 80);
|
return new Color( 0, 0, 255, 80);
|
||||||
@ -424,6 +433,16 @@ public class UITheme {
|
|||||||
return Icons.CD_OVERRIDE_SUBCOMPONENT_LIGHT;
|
return Icons.CD_OVERRIDE_SUBCOMPONENT_LIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityHiddenIcon() {
|
||||||
|
return Icons.COMPONENT_HIDDEN_LIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityShowingIcon() {
|
||||||
|
return Icons.COMPONENT_SHOWING_LIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Border getBorder() {
|
public Border getBorder() {
|
||||||
return new FlatBorder();
|
return new FlatBorder();
|
||||||
@ -755,6 +774,11 @@ public class UITheme {
|
|||||||
return getTextColor();
|
return getTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color getVisibilityHiddenForegroundColor() {
|
||||||
|
return UIManager.getColor("Tree.textForeground.hidden.dark");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getFinPointGridMajorLineColor() {
|
public Color getFinPointGridMajorLineColor() {
|
||||||
return new Color(135, 135, 199, 197);
|
return new Color(135, 135, 199, 197);
|
||||||
@ -810,6 +834,16 @@ public class UITheme {
|
|||||||
return Icons.CD_OVERRIDE_SUBCOMPONENT_DARK;
|
return Icons.CD_OVERRIDE_SUBCOMPONENT_DARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityHiddenIcon() {
|
||||||
|
return Icons.COMPONENT_HIDDEN_DARK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityShowingIcon() {
|
||||||
|
return Icons.COMPONENT_SHOWING_DARK;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Border getBorder() {
|
public Border getBorder() {
|
||||||
return new FlatBorder();
|
return new FlatBorder();
|
||||||
@ -1141,6 +1175,11 @@ public class UITheme {
|
|||||||
return getTextColor();
|
return getTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color getVisibilityHiddenForegroundColor() {
|
||||||
|
return UIManager.getColor("Tree.textForeground.hidden.dark");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getFinPointGridMajorLineColor() {
|
public Color getFinPointGridMajorLineColor() {
|
||||||
return new Color(164, 164, 224, 197);
|
return new Color(164, 164, 224, 197);
|
||||||
@ -1196,6 +1235,16 @@ public class UITheme {
|
|||||||
return Icons.CD_OVERRIDE_SUBCOMPONENT_DARK;
|
return Icons.CD_OVERRIDE_SUBCOMPONENT_DARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityHiddenIcon() {
|
||||||
|
return Icons.COMPONENT_HIDDEN_DARK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityShowingIcon() {
|
||||||
|
return Icons.COMPONENT_SHOWING_DARK;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Border getBorder() {
|
public Border getBorder() {
|
||||||
return new FlatBorder();
|
return new FlatBorder();
|
||||||
@ -1546,6 +1595,11 @@ public class UITheme {
|
|||||||
return getCurrentTheme().getComponentTreeForegroundColor();
|
return getCurrentTheme().getComponentTreeForegroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color getVisibilityHiddenForegroundColor() {
|
||||||
|
return getCurrentTheme().getVisibilityHiddenForegroundColor();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getFinPointGridMajorLineColor() {
|
public Color getFinPointGridMajorLineColor() {
|
||||||
return getCurrentTheme().getFinPointGridMajorLineColor();
|
return getCurrentTheme().getFinPointGridMajorLineColor();
|
||||||
@ -1601,6 +1655,16 @@ public class UITheme {
|
|||||||
return getCurrentTheme().getCDOverrideSubcomponentIcon();
|
return getCurrentTheme().getCDOverrideSubcomponentIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityHiddenIcon() {
|
||||||
|
return getCurrentTheme().getVisibilityHiddenIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityShowingIcon() {
|
||||||
|
return getCurrentTheme().getVisibilityHiddenIcon();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Border getBorder() {
|
public Border getBorder() {
|
||||||
return getCurrentTheme().getBorder();
|
return getCurrentTheme().getBorder();
|
||||||
|
@ -117,6 +117,12 @@ public class Icons {
|
|||||||
public static final Icon CD_OVERRIDE_SUBCOMPONENT_LIGHT = loadImageIcon("pix/icons/cd-override-subcomponent_light.png", "CD Override Subcomponent");
|
public static final Icon CD_OVERRIDE_SUBCOMPONENT_LIGHT = loadImageIcon("pix/icons/cd-override-subcomponent_light.png", "CD Override Subcomponent");
|
||||||
public static final Icon CD_OVERRIDE_SUBCOMPONENT_DARK = loadImageIcon("pix/icons/cd-override-subcomponent_dark.png", "CD Override Subcomponent");
|
public static final Icon CD_OVERRIDE_SUBCOMPONENT_DARK = loadImageIcon("pix/icons/cd-override-subcomponent_dark.png", "CD Override Subcomponent");
|
||||||
|
|
||||||
|
public static final Icon COMPONENT_HIDDEN = loadImageIcon("pix/icons/component-hidden.png", "Component Hidden");
|
||||||
|
public static final Icon COMPONENT_HIDDEN_DARK = loadImageIcon("pix/icons/component-hidden_dark.png", "Component Hidden");
|
||||||
|
public static final Icon COMPONENT_HIDDEN_LIGHT = loadImageIcon("pix/icons/component-hidden_light.png", "Component Hidden");
|
||||||
|
public static final Icon COMPONENT_SHOWING_DARK = loadImageIcon("pix/icons/component-showing_dark.png", "Component Showing");
|
||||||
|
public static final Icon COMPONENT_SHOWING_LIGHT = loadImageIcon("pix/icons/component-showing_light.png", "Component Showing");
|
||||||
|
|
||||||
// MANUFACTURERS ICONS
|
// MANUFACTURERS ICONS
|
||||||
public static final Icon RASAERO = loadImageIcon("pix/icons/RASAero_16.png", "RASAero Icon");
|
public static final Icon RASAERO = loadImageIcon("pix/icons/RASAero_16.png", "RASAero Icon");
|
||||||
public static final Icon ROCKSIM = loadImageIcon("pix/icons/Rocksim_16.png", "Rocksim Icon");
|
public static final Icon ROCKSIM = loadImageIcon("pix/icons/Rocksim_16.png", "Rocksim Icon");
|
||||||
|
BIN
swing/src/main/resources/pix/icons/component-hidden.png
Normal file
BIN
swing/src/main/resources/pix/icons/component-hidden.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
swing/src/main/resources/pix/icons/component-hidden_dark.png
Normal file
BIN
swing/src/main/resources/pix/icons/component-hidden_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
swing/src/main/resources/pix/icons/component-hidden_light.png
Normal file
BIN
swing/src/main/resources/pix/icons/component-hidden_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 364 B |
BIN
swing/src/main/resources/pix/icons/component-showing_dark.png
Normal file
BIN
swing/src/main/resources/pix/icons/component-showing_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
swing/src/main/resources/pix/icons/component-showing_light.png
Normal file
BIN
swing/src/main/resources/pix/icons/component-showing_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 306 B |
@ -9,6 +9,8 @@ Tree.paintLines = true
|
|||||||
Tree.showCellFocusIndicator = true
|
Tree.showCellFocusIndicator = true
|
||||||
Tree.wideSelection = true
|
Tree.wideSelection = true
|
||||||
Tree.paintSelection = true
|
Tree.paintSelection = true
|
||||||
|
Tree.textForeground.hidden.dark = darken($Tree.textForeground, 25%)
|
||||||
|
Tree.textForeground.hidden.light = lighten($Tree.textForeground, 25%)
|
||||||
|
|
||||||
# Margin as top,left,bottom,right
|
# Margin as top,left,bottom,right
|
||||||
Tree.rendererMargins = 2, 0, 3, 0
|
Tree.rendererMargins = 2, 0, 3, 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user