Skip to content

Commit

Permalink
Moved some general utilites to swing-utils
Browse files Browse the repository at this point in the history
* BufferedImageIcon
* KeyValueComboBox
* SwingUtil
  • Loading branch information
sebkur committed Sep 3, 2016
1 parent ed98872 commit 52db32d
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 281 deletions.
4 changes: 2 additions & 2 deletions project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ dependencies {
compile 'de.topobyte:commons-cli-helper:0.0.1'
compile 'de.topobyte:jts2awt:0.0.1'
compile 'de.topobyte:adt-tree:0.0.6'
compile 'de.topobyte:awt-utils:0.0.2'
compile 'de.topobyte:swing-utils:0.0.1'
compile 'de.topobyte:awt-utils:0.0.3'
compile 'de.topobyte:swing-utils:0.0.3'
compile 'de.topobyte:no-awt:0.0.1'
compile 'de.topobyte:no-awt-javagraphics-clipper:0.0.1'
compile 'de.topobyte:chromaticity-core:0.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import javax.swing.JPanel;

import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.core.export.SizeProvider;
import de.topobyte.livecg.core.geometry.geom.Chain;
import de.topobyte.livecg.core.painting.backend.awt.AwtPainter;
import de.topobyte.livecg.util.SwingUtil;

public class DistanceTerrain extends JPanel implements SizeProvider
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public void paint(Graphics graphics)
{
super.paint(graphics);
Graphics2D g = (Graphics2D) graphics;
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);

painter.setGraphics(g);
terrainPainter.setWidth(getWidth());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

import javax.swing.JPanel;

import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.algorithms.frechet.distanceterrain.ConfigChangedListener;
import de.topobyte.livecg.algorithms.frechet.distanceterrain.DistanceTerrainConfig;
import de.topobyte.livecg.algorithms.frechet.distanceterrain.DistanceTerrainPainterSegments;
import de.topobyte.livecg.algorithms.frechet.freespace.calc.LineSegment;
import de.topobyte.livecg.core.painting.backend.awt.AwtPainter;
import de.topobyte.livecg.ui.segmenteditor.SegmentChangeListener;
import de.topobyte.livecg.util.SwingUtil;

public class SegmentPane extends JPanel implements SegmentChangeListener,
ConfigChangedListener
Expand Down Expand Up @@ -69,7 +69,7 @@ public void paint(Graphics graphics)
{
super.paint(graphics);
Graphics2D g = (Graphics2D) graphics;
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);

painter.setGraphics(g);
terrainPainter.setWidth(getWidth());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import javax.swing.JPanel;

import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.core.export.SizeProvider;
import de.topobyte.livecg.core.geometry.geom.Chain;
import de.topobyte.livecg.core.painting.backend.awt.AwtPainter;
import de.topobyte.livecg.util.SwingUtil;

public class FreeSpaceDiagram extends JPanel implements EpsilonSettable,
SizeProvider
Expand Down Expand Up @@ -58,7 +58,7 @@ public void paint(Graphics graphics)
{
super.paint(graphics);
Graphics2D g = (Graphics2D) graphics;
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);

painter.setGraphics(g);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

import javax.swing.JPanel;

import de.topobyte.livecg.algorithms.frechet.freespace.FreeSpaceConfig;
import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.algorithms.frechet.freespace.EpsilonSettable;
import de.topobyte.livecg.algorithms.frechet.freespace.FreeSpaceConfig;
import de.topobyte.livecg.algorithms.frechet.freespace.FreeSpacePainterSegments;
import de.topobyte.livecg.algorithms.frechet.freespace.calc.FreeSpaceUtil;
import de.topobyte.livecg.algorithms.frechet.freespace.calc.Interval;
import de.topobyte.livecg.algorithms.frechet.freespace.calc.LineSegment;
import de.topobyte.livecg.core.painting.backend.awt.AwtPainter;
import de.topobyte.livecg.ui.segmenteditor.SegmentChangeListener;
import de.topobyte.livecg.util.DoubleUtil;
import de.topobyte.livecg.util.SwingUtil;

public class SegmentPane extends JPanel implements SegmentChangeListener,
EpsilonSettable
Expand Down Expand Up @@ -89,7 +89,7 @@ public void segmentChanged()
public void paint(Graphics graphics)
{
Graphics2D g = (Graphics2D) graphics;
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);

painter.setGraphics(g);
visualizationPainter.setSize(getWidth(), getHeight());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.vividsolutions.jts.operation.buffer.BufferParameters;

import de.topobyte.livecg.util.ZoomInput;
import de.topobyte.livecg.util.swing.KeyValueComboBox;
import de.topobyte.swing.util.combobox.KeyValueComboBox;

public class Settings extends JToolBar implements ItemListener, ActionListener
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import javax.swing.JPanel;

import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.algorithms.polygon.monotonepieces.SplitResult;
import de.topobyte.livecg.algorithms.polygon.triangulation.generic.TriangulationOperation;
import de.topobyte.livecg.algorithms.polygon.util.Diagonal;
Expand All @@ -39,7 +40,6 @@
import de.topobyte.livecg.core.geometry.geom.Polygon;
import de.topobyte.livecg.core.geometry.geom.PolygonHelper;
import de.topobyte.livecg.util.ShapeUtilAwt;
import de.topobyte.livecg.util.SwingUtil;
import de.topobyte.livecg.util.circular.IntRing;
import de.topobyte.livecg.util.graph.Edge;
import de.topobyte.livecg.util.graph.Graph;
Expand Down Expand Up @@ -99,7 +99,7 @@ public SleevePanel(Polygon polygon, Node nodeStart, Node nodeTarget)
public void paint(Graphics graphics)
{
Graphics2D g = (Graphics2D) graphics;
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);

Area shape = AwtHelper.toShape(polygon);
g.setColor(new Color(0x66ff0000, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
package de.topobyte.livecg.core.export;

import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.core.painting.VisualizationPainter;
import de.topobyte.livecg.core.painting.backend.awt.AwtPainter;

Expand All @@ -39,8 +39,7 @@ public static void exportPNG(File file,
BufferedImage.TYPE_4BYTE_ABGR);

Graphics2D graphics = image.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
GraphicsUtil.useAntialiasing(graphics, true);

AwtPainter painter = new AwtPainter(graphics);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.core.geometry.geom.Rectangle;
import de.topobyte.livecg.core.painting.VisualizationPainter;
import de.topobyte.livecg.core.painting.backend.awt.AwtPainter;
import de.topobyte.livecg.util.SwingUtil;

public class ScenePanel extends JPanel implements ViewportWithSignals,
HasScene, HasMargin
Expand Down Expand Up @@ -76,7 +76,7 @@ public void paint(Graphics graphics)
{
super.paint(graphics);
Graphics2D g = (Graphics2D) graphics;
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);

painter.setGraphics(g);
visualizationPainter.setWidth(getWidth());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.core.config.LiveConfig;
import de.topobyte.livecg.core.geometry.geom.Chain;
import de.topobyte.livecg.core.geometry.geom.Coordinate;
Expand All @@ -63,7 +64,6 @@
import de.topobyte.livecg.ui.geometryeditor.mousemode.MouseMode;
import de.topobyte.livecg.ui.geometryeditor.mousemode.MouseModeListener;
import de.topobyte.livecg.ui.geometryeditor.mousemode.MouseModeProvider;
import de.topobyte.livecg.util.SwingUtil;

public class GeometryEditPane extends JPanel implements MouseModeProvider,
ContentChangedListener, ViewportWithSignals, HasScene, HasMargin
Expand Down Expand Up @@ -459,7 +459,7 @@ public void paint(Graphics graphics)
{
super.paint(graphics);
Graphics2D g = (Graphics2D) graphics;
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);

AwtPainter painter = new AwtPainter(g);
paint(painter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import de.topobyte.livecg.ui.geometryeditor.Content;
import de.topobyte.livecg.ui.geometryeditor.FilePropertiesDialog;
import de.topobyte.livecg.ui.geometryeditor.GeometryEditPane;
import de.topobyte.livecg.util.SwingUtil;
import de.topobyte.swing.util.Components;

public class FilePropertiesAction extends BasicAction
{
Expand All @@ -54,7 +54,7 @@ public FilePropertiesAction(JComponent component, GeometryEditPane editPane)
@Override
public void actionPerformed(ActionEvent event)
{
JFrame frame = SwingUtil.getContainingFrame(component);
JFrame frame = Components.getContainingFrame(component);
Content content = editPane.getContent();
FilePropertiesDialog dialog = new FilePropertiesDialog(frame, content);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import de.topobyte.livecg.core.geometry.geom.Chain;
import de.topobyte.livecg.ui.action.BasicAction;
import de.topobyte.livecg.ui.geometryeditor.GeometryEditPane;
import de.topobyte.livecg.util.SwingUtil;
import de.topobyte.swing.util.Components;

public class LoadAction extends BasicAction
{
Expand All @@ -60,7 +60,7 @@ public LoadAction(JComponent component, GeometryEditPane editPane)
@Override
public void actionPerformed(ActionEvent e)
{
JFrame frame = SwingUtil.getContainingFrame(component);
JFrame frame = Components.getContainingFrame(component);
JFileChooser chooser = new JFileChooser();
int value = chooser.showOpenDialog(frame);
if (value == JFileChooser.APPROVE_OPTION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import de.topobyte.livecg.ui.action.BasicAction;
import de.topobyte.livecg.ui.geometryeditor.Content;
import de.topobyte.livecg.ui.geometryeditor.GeometryEditPane;
import de.topobyte.livecg.util.SwingUtil;
import de.topobyte.swing.util.Components;

public class OpenAction extends BasicAction
{
Expand All @@ -58,7 +58,7 @@ public OpenAction(JComponent component, GeometryEditPane editPane)
@Override
public void actionPerformed(ActionEvent event)
{
JFrame frame = SwingUtil.getContainingFrame(component);
JFrame frame = Components.getContainingFrame(component);
JFileChooser chooser = new JFileChooser();
int value = chooser.showOpenDialog(frame);
if (value == JFileChooser.APPROVE_OPTION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import de.topobyte.livecg.ui.action.BasicAction;
import de.topobyte.livecg.ui.geometryeditor.Content;
import de.topobyte.livecg.ui.geometryeditor.GeometryEditPane;
import de.topobyte.livecg.util.SwingUtil;
import de.topobyte.swing.util.Components;

public class SaveAction extends BasicAction
{
Expand All @@ -56,7 +56,7 @@ public SaveAction(JComponent component, GeometryEditPane editPane)
@Override
public void actionPerformed(ActionEvent event)
{
JFrame frame = SwingUtil.getContainingFrame(component);
JFrame frame = Components.getContainingFrame(component);
JFileChooser chooser = new JFileChooser();
int value = chooser.showSaveDialog(frame);
if (value == JFileChooser.APPROVE_OPTION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

import javax.swing.JPanel;

import de.topobyte.awt.util.GraphicsUtil;
import de.topobyte.livecg.core.geometry.geom.Chain;
import de.topobyte.livecg.core.geometry.geom.Coordinate;
import de.topobyte.livecg.core.scrolling.ViewportWithSignals;
import de.topobyte.livecg.core.scrolling.ViewportListener;
import de.topobyte.livecg.util.SwingUtil;
import de.topobyte.livecg.core.scrolling.ViewportWithSignals;

public class SegmentEditPane extends JPanel implements ViewportWithSignals
{
Expand Down Expand Up @@ -101,9 +101,9 @@ private void draw(Graphics2D g, Chain editable, Color colorLine,
Color colorPoints, Color colorPoint0)
{
int n = editable.getNumberOfNodes();
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);
// line segments
SwingUtil.useAntialiasing(g, true);
GraphicsUtil.useAntialiasing(g, true);
g.setColor(colorLine);
g.setStroke(new BasicStroke(1.0f));
Coordinate last = editable.getCoordinate(0);
Expand All @@ -116,7 +116,7 @@ private void draw(Graphics2D g, Chain editable, Color colorLine,
g.drawLine(x1, y1, x2, y2);
last = current;
}
SwingUtil.useAntialiasing(g, false);
GraphicsUtil.useAntialiasing(g, false);
// points
g.setStroke(new BasicStroke(1.0f));
for (int i = 0; i < n; i++) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.topobyte.swing.util.BufferedImageIcon;

/**
* @author Sebastian Kuerten ([email protected])
*
Expand Down Expand Up @@ -70,4 +72,5 @@ public static Icon load(String filename)
// unable to load image
return null;
}

}
Loading

0 comments on commit 52db32d

Please sign in to comment.