[fixes #816] Fix select rail button side view

This commit is contained in:
Sibo Van Gool 2021-07-17 14:15:11 +02:00
parent 38b24f5c16
commit 5427edb3aa
2 changed files with 24 additions and 14 deletions

View File

@ -3,6 +3,7 @@ package net.sf.openrocket.util;
public class Color { public class Color {
public static Color BLACK = new Color(255,255,255); public static Color BLACK = new Color(255,255,255);
public static Color INVISIBLE = new Color(1, 1, 1, 0);
private int red; private int red;
private int green; private int green;

View File

@ -1,14 +1,17 @@
package net.sf.openrocket.gui.rocketfigure; package net.sf.openrocket.gui.rocketfigure;
import java.awt.Shape; import java.awt.Shape;
import java.awt.geom.*; import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.Arrays; import java.util.Arrays;
import net.sf.openrocket.rocketcomponent.RailButton; import net.sf.openrocket.rocketcomponent.RailButton;
import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.util.Color; import net.sf.openrocket.util.Color;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.LineStyle;
import net.sf.openrocket.util.Transformation; import net.sf.openrocket.util.Transformation;
@ -64,10 +67,12 @@ public class RailButtonShapes extends RocketComponentShape {
// Invisible rectangle // Invisible rectangle
double y_invis; double y_invis;
if (baseHeightcos >= 0) if (baseHeightcos >= 0) {
y_invis = center.y; y_invis = center.y;
else }
else {
y_invis = center.y + baseHeightcos; y_invis = center.y + baseHeightcos;
}
pathInvis.append(new Rectangle2D.Double(center.x-outerRadius, y_invis, drawWidth, Math.abs(baseHeightcos)), false); pathInvis.append(new Rectangle2D.Double(center.x-outerRadius, y_invis, drawWidth, Math.abs(baseHeightcos)), false);
} }
@ -85,10 +90,12 @@ public class RailButtonShapes extends RocketComponentShape {
// Invisible rectangle // Invisible rectangle
double y_invis; double y_invis;
if (innerHeightcos >= 0) if (innerHeightcos >= 0) {
y_invis = center.y; y_invis = center.y;
else }
else {
y_invis = center.y + innerHeightcos; y_invis = center.y + innerHeightcos;
}
pathInvis.append(new Rectangle2D.Double(center.x-innerRadius, y_invis, drawWidth, Math.abs(innerHeightcos)), false); pathInvis.append(new Rectangle2D.Double(center.x-innerRadius, y_invis, drawWidth, Math.abs(innerHeightcos)), false);
} }
{// outer flange {// outer flange
@ -105,10 +112,12 @@ public class RailButtonShapes extends RocketComponentShape {
// Invisible rectangle // Invisible rectangle
double y_invis; double y_invis;
if (flangeHeightcos >= 0) if (flangeHeightcos >= 0) {
y_invis = center.y; y_invis = center.y;
else }
else {
y_invis = center.y + flangeHeightcos; y_invis = center.y + flangeHeightcos;
}
pathInvis.append(new Rectangle2D.Double(center.x-outerRadius, y_invis, drawWidth, Math.abs(flangeHeightcos)), false); pathInvis.append(new Rectangle2D.Double(center.x-outerRadius, y_invis, drawWidth, Math.abs(flangeHeightcos)), false);
} }
@ -116,7 +125,7 @@ public class RailButtonShapes extends RocketComponentShape {
RocketComponentShape[] shapesInvis = RocketComponentShape.toArray(new Shape[]{ pathInvis }, component); RocketComponentShape[] shapesInvis = RocketComponentShape.toArray(new Shape[]{ pathInvis }, component);
for (RocketComponentShape s : shapesInvis) for (RocketComponentShape s : shapesInvis)
s.setColor(new Color(1, 1, 1, 0)); s.setColor(Color.INVISIBLE);
RocketComponentShape[] total = Arrays.copyOf(shapes, shapes.length + shapesInvis.length); RocketComponentShape[] total = Arrays.copyOf(shapes, shapes.length + shapesInvis.length);
System.arraycopy(shapesInvis, 0, total, shapes.length, shapesInvis.length); System.arraycopy(shapesInvis, 0, total, shapes.length, shapesInvis.length);