mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-19 09:54:49 -04:00
added a grid to the main panel
This commit is contained in:
parent
13bf48541e
commit
87e95d03bb
@ -278,6 +278,12 @@ public final class Keys {
|
||||
public static final Key<FormatToExpression> SETTINGS_EXPRESSION_FORMAT
|
||||
= new Key<>("ExpressionFormat", FormatToExpression.FORMATTER_UNICODE);
|
||||
|
||||
/**
|
||||
* enables the grid
|
||||
*/
|
||||
public static final Key<Boolean> SETTINGS_GRID
|
||||
= new Key<>("grid", false);
|
||||
|
||||
/**
|
||||
* output format for numbers
|
||||
*/
|
||||
|
@ -603,6 +603,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
Lang.setLanguage(modified.get(Keys.SETTINGS_LANGUAGE));
|
||||
JOptionPane.showMessageDialog(Main.this, Lang.get("msg_restartNeeded"));
|
||||
}
|
||||
if (!Settings.getInstance().getAttributes().equalsKey(Keys.SETTINGS_GRID, modified))
|
||||
circuitComponent.repaintNeeded();
|
||||
Settings.getInstance().getAttributes().getValuesFrom(modified);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public final class Settings implements AttributeListener {
|
||||
intList.add(Keys.SETTINGS_LANGUAGE);
|
||||
intList.add(Keys.SETTINGS_EXPRESSION_FORMAT);
|
||||
intList.add(Keys.SETTINGS_DEFAULT_TREESELECT);
|
||||
intList.add(Keys.SETTINGS_GRID);
|
||||
intList.add(Keys.SETTINGS_ATF1502_FITTER);
|
||||
intList.add(Keys.SETTINGS_LIBRARY_PATH);
|
||||
intList.add(Keys.SETTINGS_FONT_SCALING);
|
||||
|
@ -9,6 +9,7 @@ import de.neemann.digital.core.io.InValue;
|
||||
import de.neemann.digital.draw.elements.*;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.draw.shapes.InputShape;
|
||||
import de.neemann.digital.gui.Settings;
|
||||
import de.neemann.digital.gui.components.modification.*;
|
||||
import de.neemann.digital.draw.graphics.*;
|
||||
import de.neemann.digital.draw.library.ElementLibrary;
|
||||
@ -683,6 +684,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
if (needsNewBuffer && !isManualScale)
|
||||
fitCircuit();
|
||||
|
||||
final double scaleX = transform.getScaleX();
|
||||
if (graphicsHasChanged
|
||||
|| needsNewBuffer
|
||||
|| highLighted.size() != highlightedPaintedSize) {
|
||||
@ -696,7 +698,10 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
gr2.fillRect(0, 0, getWidth(), getHeight());
|
||||
gr2.transform(transform);
|
||||
|
||||
GraphicSwing gr = new GraphicSwing(gr2, (int) (2 / transform.getScaleX()));
|
||||
if (scaleX > 0.5 && Settings.getInstance().get(Keys.SETTINGS_GRID))
|
||||
drawGrid(gr2);
|
||||
|
||||
GraphicSwing gr = new GraphicSwing(gr2, (int) (2 / scaleX));
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
circuit.drawTo(gr, highLighted, highLightStyle, modelSync);
|
||||
@ -717,11 +722,26 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
AffineTransform oldTrans = gr2.getTransform();
|
||||
gr2.transform(transform);
|
||||
enableAntiAlias(gr2);
|
||||
GraphicSwing gr = new GraphicSwing(gr2, (int) (2 / transform.getScaleX()));
|
||||
GraphicSwing gr = new GraphicSwing(gr2, (int) (2 / scaleX));
|
||||
activeMouseController.drawTo(gr);
|
||||
gr2.setTransform(oldTrans);
|
||||
}
|
||||
|
||||
private void drawGrid(Graphics2D gr2) {
|
||||
Vector g1 = raster(getPosVector(0, 0));
|
||||
Vector g2 = raster(getPosVector(getWidth(), getHeight()));
|
||||
gr2.setColor(Color.LIGHT_GRAY);
|
||||
int x = g1.x;
|
||||
while (x <= g2.x) {
|
||||
int y = g1.y;
|
||||
while (y <= g2.y) {
|
||||
gr2.drawRect(x, y, 1, 1);
|
||||
y += SIZE;
|
||||
}
|
||||
x += SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
private void enableAntiAlias(Graphics2D gr2) {
|
||||
if (antiAlias) {
|
||||
gr2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
@ -740,6 +740,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="key_activeLow_tt">Wenn gesetzt, ist der Ausgang im aktiven Zustand Low.</string>
|
||||
<string name="key_libraryPath">Bibliothek</string>
|
||||
<string name="key_libraryPath_tt">Bibliothek mit vordefinierten Schaltungen. Enthält z.B. die ICs der 74xx Reihe.</string>
|
||||
<string name="key_grid">Raster anzeigen</string>
|
||||
<string name="key_grid_tt">Zeigt im Hauptfenster ein Raster an, um das platzieren der Elemente zu erleichtern.</string>
|
||||
|
||||
<string name="mod_insertWire">Leitung eingefügt.</string>
|
||||
<string name="mod_insertCopied">Aus Zwischenablage eingefügt.</string>
|
||||
|
@ -725,6 +725,8 @@ The names of the variables may not be unique.</string>
|
||||
<string name="key_activeLow_tt">If selected the output is low if the component is active.</string>
|
||||
<string name="key_libraryPath">Library</string>
|
||||
<string name="key_libraryPath_tt">Library with predefined subcircuits. Contains, for example, the components of the 74xx series.</string>
|
||||
<string name="key_grid">Show Grid</string>
|
||||
<string name="key_grid_tt">Shows a grid in the main window.</string>
|
||||
|
||||
<string name="mod_insertWire">Inserted wire.</string>
|
||||
<string name="mod_insertCopied">Insert from clipboard.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user