Added Status bar with info about edges on walking shaperecords

This commit is contained in:
Jindra Petřík
2023-11-05 21:11:10 +01:00
parent 68d86690c8
commit fd7b9b14f8
8 changed files with 297 additions and 12 deletions
@@ -345,6 +345,12 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
listener.pointsUpdated(points);
}
}
private void fireStatusChanged(String status) {
for (MediaDisplayListener listener : listeners) {
listener.statusChanged(status);
}
}
private boolean fireEdgeSplit(int position, double splitPoint) {
boolean result = true;
@@ -429,6 +435,14 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
pointEditPanel.setVisible(false);
redraw();
}
public void setStatus(String status) {
fireStatusChanged(status);
}
public void setNoStatus() {
fireStatusChanged("");
}
public void addBoundsChangeListener(BoundsChangeListener listener) {
boundsChangeListeners.add(listener);
@@ -2809,6 +2823,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
rewind();
redraw();
fireMediaDisplayStateChanged();
fireStatusChanged("");
}
@Override
@@ -3501,6 +3516,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
soundPlayers.remove(sp);
}
}
@Override
public void statusChanged(String status) {
}
});
synchronized (ImagePanel.this) {
@@ -580,6 +580,14 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
createAndRunTempSwf(currentItem);
}
private void setStatus(String status) {
imagePlayControls.setStatus(status);
}
private void setNoStatus() {
setStatus("");
}
private JPanel createImagesCard() {
JPanel shapesCard = new JPanel(new BorderLayout());
JPanel previewPanel = new JPanel(new BorderLayout());
@@ -1180,10 +1188,15 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
//placeSplitPane.setDividerLocation(800);
displayEditTagCard.add(createDisplayEditTagButtonsPanel(), BorderLayout.SOUTH);
((GenericTagTreePanel) displayEditGenericPanel).addTreeSelectionListener(new TreeSelectionListener() {
((GenericTagTreePanel) displayEditGenericPanel).addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
JTree tree = (JTree) e.getSource();
if (e.getNewLeadSelectionPath() == null) {
displayEditImagePanel.setStatus("");
displayEditImagePanel.setHilightedEdge(null);
return;
}
JTree tree = (JTree) e.getSource();
Object obj = e.getPath().getLastPathComponent();
if (obj instanceof GenericTagTreePanel.FieldNode) {
GenericTagTreePanel.FieldNode fieldNode = (GenericTagTreePanel.FieldNode) obj;
@@ -1196,17 +1209,45 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
int x = 0;
int y = 0;
TreeModel model = tree.getModel();
int fillStyle0 = 0;
int fillStyle1 = 0;
int lineStyle = 0;
int stylesIndex = -1;
for (int i = 0; i < model.getChildCount(parent); i++) {
Object child = model.getChild(parent, i);
GenericTagTreePanel.FieldNode childFN = (GenericTagTreePanel.FieldNode) child;
SHAPERECORD rec = (SHAPERECORD) childFN.getValue(0);
if (rec instanceof StyleChangeRecord) {
StyleChangeRecord scr = (StyleChangeRecord) rec;
if (scr.stateNewStyles) {
fillStyle0 = 0;
fillStyle1 = 0;
lineStyle = 0;
stylesIndex++;
}
if (scr.stateFillStyle0) {
fillStyle0 = scr.fillStyle0;
}
if (scr.stateFillStyle1) {
fillStyle1 = scr.fillStyle1;
}
if (scr.stateLineStyle) {
lineStyle = scr.lineStyle;
}
}
if (rec == val) {
String edgeStatus = "";
if (rec instanceof StraightEdgeRecord) {
StraightEdgeRecord ser = (StraightEdgeRecord) rec;
Point point1 = new Point(x, y);
Point point2 = new Point(x + ser.deltaX, y + ser.deltaY);
Point[] hilightedPoint = new Point[]{point1, point2};
displayEditImagePanel.setHilightedEdge(hilightedPoint);
edgeStatus = AppStrings.translate("shaperecords.edge.straight")
.replace("%x1%", "" + point1.x)
.replace("%y1%", "" + point1.y)
.replace("%x2%", "" + point2.x)
.replace("%y2%", "" + point2.y);
} else if (rec instanceof CurvedEdgeRecord) {
CurvedEdgeRecord cer = (CurvedEdgeRecord) rec;
Point point1 = new Point(x, y);
@@ -1214,34 +1255,86 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
Point point3 = new Point(x + cer.controlDeltaX + cer.anchorDeltaX, y + cer.controlDeltaY + cer.anchorDeltaY);
Point[] hilightedPoint = new Point[]{point1, point2, point3};
displayEditImagePanel.setHilightedEdge(hilightedPoint);
edgeStatus = AppStrings.translate("shaperecords.edge.curved")
.replace("%x1%", "" + point1.x)
.replace("%y1%", "" + point1.y)
.replace("%x2%", "" + point2.x)
.replace("%y2%", "" + point2.y)
.replace("%x3%", "" + point3.x)
.replace("%y3%", "" + point3.y);
} else if (rec instanceof StyleChangeRecord) {
StyleChangeRecord scr = (StyleChangeRecord) rec;
StyleChangeRecord scr = (StyleChangeRecord) rec;
List<String> styleStatusParts = new ArrayList<>();
if (scr.stateMoveTo) {
Point point1 = new Point(scr.moveDeltaX, scr.moveDeltaY);
Point[] hilightedPoint = new Point[]{point1};
displayEditImagePanel.setHilightedEdge(hilightedPoint);
styleStatusParts.add(AppStrings.translate("shaperecords.edge.style.move")
.replace("%x%", "" + point1.x)
.replace("%y%", "" + point1.y));
} else {
Point point1 = new Point(x, y);
Point[] hilightedPoint = new Point[]{point1};
displayEditImagePanel.setHilightedEdge(hilightedPoint);
displayEditImagePanel.setHilightedEdge(hilightedPoint);
}
if (scr.stateNewStyles) {
int shapeNum = 0;
if (displayEditTag instanceof ShapeTag) {
shapeNum = ((ShapeTag) displayEditTag).getShapeNum();
}
if (displayEditTag instanceof MorphShapeTag) {
shapeNum = ((MorphShapeTag) displayEditTag).getShapeNum();
if (shapeNum == 2) {
shapeNum = 3;
} else {
shapeNum = 1;
}
}
styleStatusParts.add(AppStrings.translate("shaperecords.edge.style.newstyles")
.replace("%numfillstyles%", "" + scr.fillStyles.fillStyles.length)
.replace("%numlinestyles%", "" + (shapeNum < 3 ? scr.lineStyles.lineStyles.length : scr.lineStyles.lineStyles2.length))
);
}
if (scr.stateFillStyle0) {
styleStatusParts.add(AppStrings.translate("shaperecords.edge.style.fillstyle0")
.replace("%value%", "" + scr.fillStyle0));
}
if (scr.stateFillStyle1) {
styleStatusParts.add(AppStrings.translate("shaperecords.edge.style.fillstyle1")
.replace("%value%", "" + scr.fillStyle1));
}
String styleDetails = String.join(", ", styleStatusParts);
edgeStatus = AppStrings.translate("shaperecords.edge.style").replace("%details%", styleDetails);
} else if (rec instanceof EndShapeRecord) {
Point point1 = new Point(x, y);
Point[] hilightedPoint = new Point[]{point1};
displayEditImagePanel.setHilightedEdge(hilightedPoint);
edgeStatus = AppStrings.translate("shaperecords.edge.end");
} else {
displayEditImagePanel.setHilightedEdge(null);
displayEditImagePanel.setStatus("");
break;
}
String status = AppStrings.translate("shaperecords.status")
.replace("%fillstyle0%", "" + fillStyle0)
.replace("%fillstyle1%", "" + fillStyle1)
.replace("%linestyle%", "" + lineStyle)
.replace("%stylesindex%", "" + stylesIndex)
.replace("%edge%", edgeStatus);
displayEditImagePanel.setStatus(status);
break;
}
x = rec.changeX(x);
y = rec.changeY(y);
}
} else {
displayEditImagePanel.setStatus("");
displayEditImagePanel.setHilightedEdge(null);
}
} else {
displayEditImagePanel.setStatus("");
displayEditImagePanel.setHilightedEdge(null);
}
}
@@ -1209,4 +1209,16 @@ tag.morphshape.create = Create morphshape from shape files...
dialog.morphshape.startShape = Select start shape.
dialog.morphshape.endShape = Select end shape. Click cancel to make end shape same as the start shape.
error.morphshape.incompatible = Cannot create morphshape: Start and end shape have incompatible fill/line styles.
error.morphshape.incompatible = Cannot create morphshape: Start and end shape have incompatible fill/line styles.
shaperecords.status = FillStyle0: %fillstyle0%, FillStyle1: %fillstyle1%, LineStyle: %linestyle%, StylesIndex %stylesindex%, %edge%
shaperecords.edge.straight = Straight edge from %x1%, %y1% to %x2%, %y2%
shaperecords.edge.curved = Curved edge from %x1%, %y1% control %x2%, %y2% anchor %x3%, %y3%
shaperecords.edge.style = Style change (%details%)
shaperecords.edge.style.move = Move to %x%, %y%
shaperecords.edge.style.newstyles = New styles - %numfillstyles%x fillstyle + %numlinestyles%x linestyle
shaperecords.edge.style.fillstyle0 = FillStyle0 = %value%
shaperecords.edge.style.fillstyle1 = FillStyle1 = %value%
shaperecords.edge.end = Shape end
@@ -1186,4 +1186,14 @@ tag.morphshape.create = Vytvo\u0159it morphshape ze soubor\u016f tvar\u016f...
dialog.morphshape.startShape = Vyberte po\u010d\u00e1te\u010dn\u00ed tvar.
dialog.morphshape.endShape = Vyberte koncov\u00fd tvar. Klikn\u011bte na Storno pro nastaven\u00ed stejn\u00e9ho jako je po\u010d\u00e1te\u010dn\u00ed.
error.morphshape.incompatible = Nelze vytvo\u0159it morphshape: Po\u010d\u00e1te\u010dn\u00ed a koncov\u00fd tvar maj\u00ed nekompatibiln\u00ed styl v\u00fdpln\u011b/ohrani\u010den\u00ed.
error.morphshape.incompatible = Nelze vytvo\u0159it morphshape: Po\u010d\u00e1te\u010dn\u00ed a koncov\u00fd tvar maj\u00ed nekompatibiln\u00ed styl v\u00fdpln\u011b/ohrani\u010den\u00ed.
shaperecords.status = FillStyle0: %fillstyle0%, FillStyle1: %fillstyle1%, LineStyle: %linestyle%, IndexStylu %stylesindex%, %edge%
shaperecords.edge.straight = Rovn\u00e1 hrana z %x1%, %y1% do %x2%, %y2%
shaperecords.edge.curved = Zaoblen\u00e1 hrana z %x1%, %y1% control %x2%, %y2% anchor %x3%, %y3%
shaperecords.edge.style = Zm\u011bna stylu (%details%)
shaperecords.edge.style.move = P\u0159esun na %x%, %y%
shaperecords.edge.style.newstyles = Nov\u00e9 styly - %numfillstyles%x fillstyle + %numlinestyles%x linestyle
shaperecords.edge.style.fillstyle0 = FillStyle0 = %value%
shaperecords.edge.style.fillstyle1 = FillStyle1 = %value%
shaperecords.edge.end = Konec tvaru
@@ -22,7 +22,9 @@ package com.jpexs.decompiler.flash.gui.player;
*/
public interface MediaDisplayListener {
void mediaDisplayStateChanged(MediaDisplay source);
public void mediaDisplayStateChanged(MediaDisplay source);
void playingFinished(MediaDisplay source);
public void playingFinished(MediaDisplay source);
public void statusChanged(String status);
}
@@ -116,6 +116,8 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
private final JToggleButton freezeButton;
private final JToggleButton muteButton;
private final JTextField statusTextField;
public static final int ZOOM_DECADE_STEPS = 10;
@@ -131,7 +133,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
private final int zeroCharacterWidth;
private final double MAX_ZOOM = 1.0e6; //in larger zooms, flash viewer stops working
private final double MAX_ZOOM = 1.0e6; //in larger zooms, flash viewer stops working
static {
Font font = new JLabel().getFont();
@@ -144,7 +146,15 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
public PlayerControls(final MainPanel mainPanel, MediaDisplay display, JPanel middleButtonsPanel) {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
statusTextField = new JTextField(50);
statusTextField.setEditable(false);
statusTextField.setBorder(null);
statusTextField.setBackground(null);
//statusTextField.setVisible(true);
statusTextField.setOpaque(false);
add(statusTextField);
graphicControls = new JPanel(new BorderLayout());
JPanel graphicButtonsPanel = new JPanel(new FlowLayout());
JButton selectColorButton = new JButton(View.getIcon("color16"));
@@ -330,11 +340,16 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
});
playbackControls.add(progress);
playbackControls.add(controlPanel);
add(playbackControls);
add(playbackControls);
this.display.addEventListener(this);
}
public void setStatus(String status) {
statusTextField.setText(status);
//statusTextField.setVisible(!status.isEmpty());
}
private String formatMs(long ms) {
long s = ms / 1000;
ms %= 1000;
@@ -629,6 +644,11 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
public void playingFinished(MediaDisplay source) {
}
@Override
public void statusChanged(String status) {
setStatus(status);
}
private class TransferableImage implements Transferable {
Image img;