Skip to content

Commit

Permalink
Add option to change worksheet size
Browse files Browse the repository at this point in the history
  • Loading branch information
kristian committed Feb 6, 2024
1 parent 6d00157 commit 7e77d83
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ jobs:
draft: true
files: staging/*
fail_on_unmatched_files: true
body: "[${{ github.event.head_commit.message }}](https://github.com/kristian/JDigitalSimulator/commit/${{ github.event.head_commit.id }})"
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Application",
"request": "launch",
"mainClass": "lc.kra.jds.gui.Application",
"projectName": "jds",
"vmArgs": "--add-opens java.base/java.io=ALL-UNNAMED"
}
]
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.4.0 (2024-02-05)
### Added
- Option to change worksheet size

## 2.3.0 (2024-02-05)
### Fixed
- Ability to open files from old JDigitalSimulator versions (before open-sourcing, version < 1.*), see the README.md instructions
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>lc.kra.jds</groupId>
<artifactId>jds</artifactId>
<version>2.3.0</version>
<version>2.4.0</version>

<name>JDigitalSimulator</name>
<description>JDigitalSimulator is a plattform independend Electronic Design Automation software entirely build in Java</description>
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/lc/kra/jds/Simulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public class Simulation extends JComponent implements Scrollable, Printable {
private static final long serialVersionUID = 1l;

public enum Layer { TOPMOST, BOTTOMMOST; }
public static final Dimension DEFAULT_SIZE = new Dimension(2000, 2000);

private static final Color SELECTION = new Color(10, 200, 10, 75);
private static final Dimension SIZE = new Dimension(2000, 2000);
private static final int GRID_STEPS = 20;
private static final int STACK_SIZE = 200;

Expand Down Expand Up @@ -196,7 +196,7 @@ private void initialize() {
future = new LinkedList<ChangeEvent>();
this.setZoom(1.0d);
this.setFocusable(true);
this.setPreferredSize(SIZE);
this.setPreferredSize(properties.size != null ? properties.size : DEFAULT_SIZE);
initializeListeners();
initializeDropTarget();
}
Expand Down Expand Up @@ -466,10 +466,11 @@ public void mouseDragged(MouseEvent event) {
}

GraphicsConfiguration context = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
dragImage = context.createCompatibleImage(SIZE.height, SIZE.width, Transparency.TRANSLUCENT);
Dimension size = getPreferredSize();
dragImage = context.createCompatibleImage(size.height, size.width, Transparency.TRANSLUCENT);
Graphics2D graphics = prepareGraphics(dragImage.createGraphics());
graphics.setColor(new Color(0, 0, 0, 0));
graphics.fillRect(0, 0, SIZE.height, SIZE.width);
graphics.fillRect(0, 0, size.height, size.width);
paintComponents(graphics, dragComponents, dragWires);
} else if(selectWire!=null) {
selectWire.setPreferredLocation(event.getPoint());
Expand Down Expand Up @@ -1205,6 +1206,7 @@ public static class SimulationProperies implements Serializable {

public AuthorDescription author = new AuthorDescription();
public CircuitDescription circuit = new CircuitDescription();
public Dimension size = DEFAULT_SIZE;
private String hash;

public class AuthorDescription implements Serializable {
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/lc/kra/jds/gui/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JSeparator;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
Expand All @@ -113,6 +114,7 @@
import javax.swing.JToolBar;
import javax.swing.JViewport;
import javax.swing.JWindow;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.TransferHandler;
import javax.swing.UIManager;
Expand Down Expand Up @@ -140,15 +142,15 @@
/**
* JDigitalSimulator
* @author Kristian Kraljic
* @version 2.3.0
* @version 2.4.0
*/
public class Application extends JFrame {
private static final long serialVersionUID = -4693271310855486553L;

public static final String FILE_EXTENSION = "jdsim";
public static File pluginDirectory, currentDirectory;

private static final String VERSION = "2.3.0", COPYRIGHT = "2010-2024", LINES_OF_CODE = "9.509", WORDS_OF_CODE = "36.133", PAGES_OF_CODE = "245";
private static final String VERSION = "2.4.0", COPYRIGHT = "2010-2024", LINES_OF_CODE = "9.509", WORDS_OF_CODE = "36.133", PAGES_OF_CODE = "245";

private static final String[]
TOOLBAR_FRAME_FOCUS = new String[]{"save", "print", "print_level", "simulate", "left", "right", "up", "down", "grid", "secure", "zoom_default", "zoom", "zoom_in", "zoom_out"},
Expand Down Expand Up @@ -502,8 +504,8 @@ private JMenuBar createMenuBar() {
properties.add(createMenuItem("properties.worksheet", new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
SimulationFrame frame = desktop.getSelectedFrame();
Simulation simulation = frame.getSimulation();
final SimulationFrame frame = desktop.getSelectedFrame();
final Simulation simulation = frame.getSimulation();
final Simulation.SimulationProperies properties = simulation.properties;
String fileName = getTranslation("properties.worksheet", TranslationType.TITLE, frame.getFileName());
final JDialog dialog = Guitilities.createDialog(Application.this, fileName);
Expand All @@ -527,6 +529,12 @@ public void actionPerformed(ActionEvent event) {
final JTextField circuitVersion = Guitilities.addGridPairLine(circuitPane, 2, new JLabel(getTranslation("properties.circuit.version")), new JTextField(properties.circuit.version));
centerPane.add(circuitPane);

centerPane.add(Guitilities.createSeparator(getTranslation("properties.worksheet")));
JPanel worksheetPane = new JPanel(new GridBagLayout());
final JSpinner worksheetWidth = Guitilities.addGridPairLine(worksheetPane, 0, new JLabel(getTranslation("properties.worksheet.width")), new JSpinner(new SpinnerNumberModel((properties.size != null ? properties.size : Simulation.DEFAULT_SIZE).getWidth(), 100, Short.MAX_VALUE, 100)), new JLabel(getTranslation("properties.worksheet.pixels")));
final JSpinner worksheetHeight = Guitilities.addGridPairLine(worksheetPane, 1, new JLabel(getTranslation("properties.worksheet.height")), new JSpinner(new SpinnerNumberModel((properties.size != null ? properties.size : Simulation.DEFAULT_SIZE).getHeight(), 100, Short.MAX_VALUE, 100)), new JLabel(getTranslation("properties.worksheet.pixels")));
centerPane.add(worksheetPane);

JPanel bottomPane = Guitilities.createGradientFooter();
bottomPane.add(Guitilities.createButton(getTranslation("properties.secure"), new ActionListener() {
@Override public void actionPerformed(ActionEvent event) { getToolBarButton("secure").getActionListeners()[0].actionPerformed(event); }
Expand All @@ -541,6 +549,8 @@ public void actionPerformed(ActionEvent event) {
properties.circuit.name = circuitName.getText();
properties.circuit.description = ((JTextArea)circuitDescription.getViewport().getComponent(0)).getText();
properties.circuit.version = circuitVersion.getText();
properties.size.setSize((double) worksheetWidth.getValue(), (double) worksheetHeight.getValue());
simulation.setPreferredSize(properties.size); if (simulation.getParent() != null) simulation.getParent().revalidate();
}
};
bottomPane.add(Guitilities.createButton(getTranslation("properties.okay"), new ActionListener() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/lc/kra/jds/TranslationBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ properties.circuit = Circuit
properties.circuit.name = Name:
properties.circuit.description = Description:
properties.circuit.version = Version:
properties.worksheet = Worksheet
properties.worksheet.width = Width:
properties.worksheet.height = Height:
properties.worksheet.pixels = pixels
properties.localization = Language options
properties.localization.language = Language:
properties.localization.info = Note: You will have to restart the JDigitalSimulator in order to complete the change of the default display language completely.
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/lc/kra/jds/TranslationBundle_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ properties.circuit = Schaltung
properties.circuit.name = Name:
properties.circuit.description = Beschreibung:
properties.circuit.version = Version:
properties.worksheet = Arbeitsblatt
properties.worksheet.width = Breite:
properties.worksheet.height = Höhe:
properties.worksheet.pixels = Pixel
properties.localization = Spracheinstellungen
properties.localization.language = Sprache:
properties.localization.info = Hinweis: Sie müssen den JDigitalSimulator neustarten damit die Sprachänderungen vollständig wirksam werden.
Expand Down

0 comments on commit 7e77d83

Please sign in to comment.