mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
tweak colors
This commit is contained in:
@@ -6,14 +6,14 @@
|
||||
<unit class="org.diylc.core.measures.ResistanceUnit">K</unit>
|
||||
</org.diylc.core.measures.Resistance>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lastPath</string>
|
||||
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>metric</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lastPath</string>
|
||||
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>default.org.diylc.components.semiconductors.DIL_IC:Value</string>
|
||||
<string>LM366</string>
|
||||
|
||||
Binary file not shown.
+8
@@ -0,0 +1,8 @@
|
||||
package org.diylc.common;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public interface IComponentFiler {
|
||||
|
||||
boolean testComponent(IDIYComponent<?> component);
|
||||
}
|
||||
+6
-2
@@ -83,11 +83,15 @@ public interface IPlugInPort {
|
||||
Map<String, List<ComponentType>> getComponentTypes();
|
||||
|
||||
/**
|
||||
* Draws project on the provided {@link Graphics2D}.
|
||||
* Draws project on the provided {@link Graphics2D}. If the provided filter
|
||||
* is not null, it will be used to filter the components that are shown.
|
||||
*
|
||||
* @param g2d
|
||||
* @param drawOptions
|
||||
* specific drawing options
|
||||
* @param filter
|
||||
*/
|
||||
void draw(Graphics2D g2d, Set<DrawOption> drawProperties);
|
||||
void draw(Graphics2D g2d, Set<DrawOption> drawOptions, IComponentFiler filter);
|
||||
|
||||
/**
|
||||
* Injects a custom GUI panels provided by the plug-in and desired position
|
||||
|
||||
+7
-9
@@ -71,16 +71,14 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
(points[0].y + points[1].y - shapeRect.height) / 2);
|
||||
g2d.rotate(theta, shapeRect.width / 2, shapeRect.height / 2);
|
||||
// Draw body.
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||
/ MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(bodyColor);
|
||||
g2d.fill(shape);
|
||||
g2d.setComposite(oldComposite);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||
/ MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(bodyColor);
|
||||
g2d.fill(shape);
|
||||
g2d.setComposite(oldComposite);
|
||||
g2d.setStroke(new BasicStroke(1));
|
||||
g2d.setColor(componentState == ComponentState.SELECTED
|
||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||
|
||||
+3
-3
@@ -107,7 +107,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
bufferImage = createImage(getWidth(), getHeight());
|
||||
}
|
||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||
plugInPort.draw(g2d, drawOptions);
|
||||
plugInPort.draw(g2d, drawOptions, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +119,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
createBufferImage();
|
||||
} else {
|
||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||
plugInPort.draw(g2d, drawOptions);
|
||||
plugInPort.draw(g2d, drawOptions, null);
|
||||
}
|
||||
if (USE_HARDWARE_ACCELLERATION) {
|
||||
VolatileImage volatileImage = (VolatileImage) bufferImage;
|
||||
@@ -139,7 +139,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
} while (volatileImage == null || volatileImage.contentsLost());
|
||||
} else {
|
||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||
plugInPort.draw(g2d, drawOptions);
|
||||
plugInPort.draw(g2d, drawOptions, null);
|
||||
g.drawImage(bufferImage, 0, 0, this);
|
||||
bufferImage.flush();
|
||||
}
|
||||
|
||||
+8
-2
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IComponentFiler;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
|
||||
import com.diyfever.gui.IDrawingProvider;
|
||||
@@ -18,7 +19,7 @@ import com.diyfever.gui.IDrawingProvider;
|
||||
*/
|
||||
public class ProjectDrawingProvider implements IDrawingProvider {
|
||||
|
||||
IPlugInPort plugInPort;
|
||||
private IPlugInPort plugInPort;
|
||||
|
||||
public ProjectDrawingProvider(IPlugInPort plugInPort) {
|
||||
super();
|
||||
@@ -27,7 +28,12 @@ public class ProjectDrawingProvider implements IDrawingProvider {
|
||||
|
||||
@Override
|
||||
public void draw(Graphics g) {
|
||||
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ZOOM, DrawOption.ANTIALIASING));
|
||||
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ZOOM, DrawOption.ANTIALIASING), null);
|
||||
}
|
||||
|
||||
public void draw(Graphics g, IComponentFiler filter) {
|
||||
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ZOOM, DrawOption.ANTIALIASING),
|
||||
filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -132,14 +132,14 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
|
||||
zoomRatio = rect.getHeight() / d.getHeight();
|
||||
}
|
||||
// d.setSize(d.getWidth() * zoomRatio, d.getHeight() * zoomRatio);
|
||||
int x = (int) (rect.getWidth() - d.getWidth() * zoomRatio) / 2;
|
||||
int y = (int) (rect.getHeight() - d.getHeight() * zoomRatio) / 2;
|
||||
// int x = (int) (rect.getWidth() - d.getWidth() * zoomRatio) / 2;
|
||||
// int y = (int) (rect.getHeight() - d.getHeight() * zoomRatio) / 2;
|
||||
|
||||
// System.out.println(x + "," + y);
|
||||
|
||||
g2d.translate(x, y);
|
||||
// g2d.translate(x, y);
|
||||
g2d.scale(zoomRatio, zoomRatio);
|
||||
presenter.draw(g2d, EnumSet.noneOf(DrawOption.class));
|
||||
presenter.draw(g2d, EnumSet.noneOf(DrawOption.class), null);
|
||||
|
||||
g2d.setColor(Color.black);
|
||||
g2d.drawRect(0, 0, d.width - (int) (1 / zoomRatio), d.height - (int) (1 / zoomRatio));
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IComponentFiler;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class ComponentZOrderFiler implements IComponentFiler {
|
||||
|
||||
private int zOrder;
|
||||
|
||||
public ComponentZOrderFiler(int zOrder) {
|
||||
super();
|
||||
this.zOrder = zOrder;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean testComponent(IDIYComponent<?> component) {
|
||||
ComponentType componentType = ComponentProcessor.getInstance().createComponentTypeFrom(
|
||||
(Class<? extends IDIYComponent<?>>) component.getClass());
|
||||
return Math.round(componentType.getZOrder()) == zOrder;
|
||||
}
|
||||
}
|
||||
+11
-7
@@ -8,7 +8,6 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -31,6 +30,7 @@ import org.diylc.common.ComponentSelection;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentFiler;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
@@ -215,7 +215,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, Set<DrawOption> drawOptions) {
|
||||
public void draw(Graphics2D g2d, Set<DrawOption> drawOptions, IComponentFiler filter) {
|
||||
if (currentProject == null) {
|
||||
return;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class Presenter implements IPlugInPort {
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
}
|
||||
|
||||
AffineTransform initialTx = g2d.getTransform();
|
||||
// AffineTransform initialTx = g2d.getTransform();
|
||||
Dimension d = getCanvasDimensions(drawOptions.contains(DrawOption.ZOOM));
|
||||
|
||||
g2dWrapper.setColor(Constants.CANVAS_COLOR);
|
||||
@@ -259,6 +259,10 @@ public class Presenter implements IPlugInPort {
|
||||
componentAreaMap.clear();
|
||||
if (components != null) {
|
||||
for (IDIYComponent<?> component : components) {
|
||||
// Do not draw the component if it's filtered out.
|
||||
if (filter != null && !filter.testComponent(component)) {
|
||||
continue;
|
||||
}
|
||||
g2dWrapper.startedDrawingComponent();
|
||||
ComponentState state = ComponentState.NORMAL;
|
||||
if (drawOptions.contains(DrawOption.SELECTION)
|
||||
@@ -299,10 +303,10 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
// Go back to the original transformation and zoom in to draw the
|
||||
// selection rectangle and other similar elements.
|
||||
g2d.setTransform(initialTx);
|
||||
if ((drawOptions.contains(DrawOption.ZOOM)) && (Math.abs(1.0 - zoomLevel) > 1e-4)) {
|
||||
g2d.scale(zoomLevel, zoomLevel);
|
||||
}
|
||||
// g2d.setTransform(initialTx);
|
||||
// if ((drawOptions.contains(DrawOption.ZOOM)) && (Math.abs(1.0 - zoomLevel) > 1e-4)) {
|
||||
// g2d.scale(zoomLevel, zoomLevel);
|
||||
// }
|
||||
|
||||
// At the end draw selection rectangle if needed.
|
||||
if (drawOptions.contains(DrawOption.SELECTION) && (selectionRect != null)) {
|
||||
|
||||
Reference in New Issue
Block a user