mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-03 18:44:46 +00:00
Added: Configure grid and guides color
This commit is contained in:
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.helpers.FontHelper;
|
||||
import com.jpexs.decompiler.flash.importers.TextImportResizeTextBoundsMode;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@@ -1101,6 +1102,14 @@ public final class Configuration {
|
||||
@ConfigurationCategory("display")
|
||||
public static ConfigurationItem<Boolean> gridOverObjects = null;
|
||||
|
||||
@ConfigurationDefaultColor("#949494")
|
||||
@ConfigurationCategory("display")
|
||||
public static ConfigurationItem<Color> gridColor = null;
|
||||
|
||||
@ConfigurationDefaultColor("#00FF00")
|
||||
@ConfigurationCategory("display")
|
||||
public static ConfigurationItem<Color> guidesColor = null;
|
||||
|
||||
private enum OSId {
|
||||
WINDOWS, OSX, UNIX
|
||||
}
|
||||
@@ -1484,6 +1493,17 @@ public final class Configuration {
|
||||
mingc.setTime(new Date(aCalendar.value()));
|
||||
defaultValue = mingc;
|
||||
}
|
||||
|
||||
ConfigurationDefaultColor aColor = field.getAnnotation(ConfigurationDefaultColor.class);
|
||||
if (aColor != null) {
|
||||
Pattern p = Pattern.compile("#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$");
|
||||
Matcher m = p.matcher(aColor.value());
|
||||
if (m.matches()) {
|
||||
defaultValue = new Color(Integer.parseInt(m.group(1), 16), Integer.parseInt(m.group(2), 16), Integer.parseInt(m.group(3), 16));
|
||||
} else {
|
||||
defaultValue = Color.black;
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2024 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.configuration;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Configuration default Color annotation.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ConfigurationDefaultColor {
|
||||
|
||||
String value();
|
||||
}
|
||||
@@ -35,6 +35,8 @@ import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
@@ -55,6 +57,7 @@ import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
@@ -68,6 +71,8 @@ import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import org.pushingpixels.substance.api.ColorSchemeAssociationKind;
|
||||
import org.pushingpixels.substance.api.ComponentState;
|
||||
@@ -409,6 +414,9 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
Logger.getLogger(AdvancedSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
if (itemType == Color.class) {
|
||||
defaultValue = ConfigurationColorSelection.colorToHex((Color) defaultValue);
|
||||
}
|
||||
String locNameHtml = locName;
|
||||
if (!filter.trim().equals("")) {
|
||||
locNameHtml = Pattern.compile(Pattern.quote(filter), Pattern.UNICODE_CASE + Pattern.CASE_INSENSITIVE).matcher(locNameHtml).replaceAll("{bold}$0{/bold}");
|
||||
@@ -464,6 +472,11 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
cb.setSelected((Boolean) item.get());
|
||||
cb.setToolTipText(description);
|
||||
c = cb;
|
||||
} else if (itemType == Color.class) {
|
||||
ConfigurationColorSelection cb = new ConfigurationColorSelection(item, (Color) item.get(), description);
|
||||
|
||||
cb.setMaximumSize(new Dimension(Integer.MAX_VALUE, cb.getPreferredSize().height));
|
||||
c = cb;
|
||||
} else if (itemType.isEnum()) {
|
||||
JComboBox<String> cb = new JComboBox<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -575,6 +588,9 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
if (itemType == Boolean.class) {
|
||||
value = ((JCheckBox) c).isSelected();
|
||||
}
|
||||
if (itemType == Color.class) {
|
||||
value = ((ConfigurationColorSelection) c).getValue();
|
||||
}
|
||||
|
||||
if (itemType == Calendar.class) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2025 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.configuration.ConfigurationItem;
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.BevelBorder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ConfigurationColorSelection extends JPanel {
|
||||
private JPanel colorPanel;
|
||||
|
||||
public ConfigurationColorSelection(ConfigurationItem item, Color value, String description) {
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
colorPanel = new JPanel();
|
||||
colorPanel.setToolTipText(description);
|
||||
colorPanel.setSize(16, 16);
|
||||
colorPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
JLabel colorLabel = new JLabel();
|
||||
colorPanel.setBackground(value);
|
||||
|
||||
colorPanel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
colorPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
colorPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
Color newColor = ViewMessages.showColorDialog(colorPanel, colorPanel.getBackground(), false);
|
||||
if (newColor != null) {
|
||||
colorPanel.setBackground(newColor);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
colorLabel.setText(colorToHex(value));
|
||||
colorLabel.setToolTipText(description);
|
||||
|
||||
|
||||
add(colorPanel);
|
||||
add(colorLabel);
|
||||
}
|
||||
|
||||
public static String colorToHex(Color value) {
|
||||
String rh = Integer.toHexString(value.getRed());
|
||||
if (rh.length() < 2) {
|
||||
rh = "0" + rh;
|
||||
}
|
||||
String gh = Integer.toHexString(value.getGreen());
|
||||
if (gh.length() < 2) {
|
||||
gh = "0" + gh;
|
||||
}
|
||||
String bh = Integer.toHexString(value.getBlue());
|
||||
if (bh.length() < 2) {
|
||||
bh = "0" + bh;
|
||||
}
|
||||
return "#" + rh + gh + bh;
|
||||
}
|
||||
|
||||
public Color getValue() {
|
||||
return colorPanel.getBackground();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -385,8 +385,6 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
|
||||
|
||||
private List<Double> guidesY = new ArrayList<>();
|
||||
|
||||
private static final Color GUIDES_COLOR = Color.green;
|
||||
|
||||
private static final int GUIDE_THICKNESS = 20;
|
||||
|
||||
private static final int GUIDE_FONT_HEIGHT = 11;
|
||||
@@ -912,7 +910,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
|
||||
}
|
||||
|
||||
private static void drawGridSwf(Graphics2D g, Rectangle realRect, double zoom) {
|
||||
g.setColor(new Color(0x94, 0x94, 0x94));
|
||||
g.setColor(Configuration.gridColor.get());
|
||||
double x;
|
||||
double y;
|
||||
int ix;
|
||||
@@ -1011,7 +1009,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
|
||||
|
||||
private void drawGridNoSwf(Graphics2D g2, int x, int y) {
|
||||
double zoomDouble = getRealZoom();
|
||||
g2.setColor(new Color(0x94, 0x94, 0x94));
|
||||
g2.setColor(Configuration.gridColor.get());
|
||||
double gx;
|
||||
double gy;
|
||||
int ix = 0;
|
||||
@@ -3298,7 +3296,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
g2d.setColor(GUIDES_COLOR);
|
||||
g2d.setColor(Configuration.guidesColor.get());
|
||||
if (draggingGuideX && lastMouseEvent != null) {
|
||||
g2d.drawLine(guideDragX, 0, guideDragX, getHeight());
|
||||
}
|
||||
@@ -3737,7 +3735,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
|
||||
g2.fillRect(0, 0, GUIDE_THICKNESS, GUIDE_THICKNESS);
|
||||
|
||||
if (guideDragX > -1) {
|
||||
g2.setColor(GUIDES_COLOR);
|
||||
g2.setColor(Configuration.guidesColor.get());
|
||||
g2.drawLine(GUIDE_THICKNESS + guideDragX, 0, GUIDE_THICKNESS + guideDragX, GUIDE_THICKNESS);
|
||||
}
|
||||
|
||||
@@ -3811,7 +3809,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
|
||||
g2.draw(gp);
|
||||
|
||||
if (guideDragY > -1) {
|
||||
g2.setColor(GUIDES_COLOR);
|
||||
g2.setColor(Configuration.guidesColor.get());
|
||||
g2.drawLine(0, guideDragY, GUIDE_THICKNESS, guideDragY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,3 +593,8 @@ config.description.snapToGrid = Enables snapping cursor to grid while moving obj
|
||||
config.name.gridOverObjects = Show grid over objects
|
||||
config.description.gridOverObjects = When the grid is displayed, it is shown over objects on stage.
|
||||
|
||||
config.name.gridColor = Grid color
|
||||
config.description.gridColor = Color of the drawn grid.
|
||||
|
||||
config.name.guidesColor = Guides color
|
||||
config.description.guidesColor = Color of the drawn guides.
|
||||
|
||||
Reference in New Issue
Block a user