summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/graph/Graph.java
diff options
context:
space:
mode:
authorSimon Rettberg2023-09-27 18:31:32 +0200
committerSimon Rettberg2023-09-27 18:31:32 +0200
commit7de5c49c0da40932d30eff97601911b04895dfee (patch)
treea356138580b5f00494c5a0699891b1b71cda7cec /src/main/java/org/openslx/graph/Graph.java
parentWork around race condition instead of proper rearchitecturing (diff)
downloaddnbd3-status-7de5c49c0da40932d30eff97601911b04895dfee.tar.gz
dnbd3-status-7de5c49c0da40932d30eff97601911b04895dfee.tar.xz
dnbd3-status-7de5c49c0da40932d30eff97601911b04895dfee.zip
Remove legacy PNG output mode
Diffstat (limited to 'src/main/java/org/openslx/graph/Graph.java')
-rw-r--r--src/main/java/org/openslx/graph/Graph.java129
1 files changed, 0 insertions, 129 deletions
diff --git a/src/main/java/org/openslx/graph/Graph.java b/src/main/java/org/openslx/graph/Graph.java
index 7f7ca64..4f2fc90 100644
--- a/src/main/java/org/openslx/graph/Graph.java
+++ b/src/main/java/org/openslx/graph/Graph.java
@@ -1,16 +1,7 @@
package org.openslx.graph;
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.Stroke;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -48,26 +39,12 @@ public class Graph implements java.io.Serializable
private int _frameCount = 0;
- private static final Color COLOR_BG = new Color( 250, 250, 255 );
- private static final Color COLOR_TITLE = new Color( 200, 200, 255 );
- private static final Color COLOR_LABEL = new Color( 0, 0, 20 );
- private static final Color COLOR_LABEL_SHADOW = new Color( 220, 220, 220 );
- private static final Color COLOR_TITLE2 = new Color( 190, 190, 210 );
- private static final Color COLOR_EDGE = new Color( 100, 100, 255 );
-
private static final int IMG_X = 1280;
private static final int IMG_Y = 1024;
- private final Graphics2D graphicsContext;
- private final PngRenderer renderer;
-
public Graph( String label )
{
_label = label;
- BufferedImage targetImage = new BufferedImage( IMG_X, IMG_Y, BufferedImage.TYPE_INT_ARGB );
- graphicsContext = targetImage.createGraphics();
- graphicsContext.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
- renderer = new PngRenderer( targetImage );
}
// Add a Node to the Graph.
@@ -420,68 +397,6 @@ public class Graph implements java.io.Serializable
}
- private static final Font FONT_64 = new Font( "SansSerif", Font.BOLD, 64 );
- private static final Font FONT_18 = new Font( "SansSerif", Font.BOLD, 18 );
- private static final Font FONT_12 = new Font( "SansSerif", Font.PLAIN, 12 );
- private static final Font FONT_10 = new Font( "SansSerif", Font.PLAIN, 10 );
- private static final Stroke STROKE_2 = new BasicStroke( 2.0f );
-
- public void drawImage( Set<Node> nodes, double edgeThreshold )
- {
-
- // Now actually draw the thing...
-
- graphicsContext.setColor( COLOR_BG );
- graphicsContext.fillRect( 0, 0, IMG_X, IMG_Y );
-
- graphicsContext.setColor( COLOR_TITLE );
- graphicsContext.setFont( FONT_64 );
- graphicsContext.drawString( _label, 20, 80 );
-
- graphicsContext.setColor( COLOR_TITLE2 );
- graphicsContext.setFont( FONT_18 );
- graphicsContext.drawString( _caption, 0, IMG_Y - 5 - 50 );
- graphicsContext.setFont( FONT_12 );
- graphicsContext.drawString( "This frame was drawn at " + new Date(), 0, IMG_Y - 5 );
-
- // Draw all edges...
- for ( Edge edge : _edges.values() ) {
- if ( edge.getWeight() < edgeThreshold ) {
- continue;
- }
-
- double weight = edge.getWeight();
-
- Node nodeA = edge.getSource();
- Node nodeB = edge.getTarget();
- int x1 = toImageX( nodeA );
- int y1 = toImageY( nodeA );
- int x2 = toImageX( nodeB );
- int y2 = toImageY( nodeB );
- graphicsContext.setStroke( new BasicStroke( (float) ( FastMath.log( weight + 1 ) * 0.1 ) + 1 ) );
- final int alpha = 102 + (int) ( 153 * weight / maxWeight );
- graphicsContext.setColor( new Color( ( edge.getColor().getRGB() & 0xffffff ) | ( alpha << 24 ), true ) );
- graphicsContext.drawLine( x1, y1, x2, y2 );
- }
-
- // Draw all nodes...
- graphicsContext.setStroke( STROKE_2 );
- graphicsContext.setFont( FONT_10 );
- for ( Node node : nodes ) {
- final int x = toImageX( node );
- final int y = toImageY( node );
- final int nodeRadius = node.getRadius();
- graphicsContext.setColor( node.getColor() );
- graphicsContext.fillOval( x - nodeRadius, y - nodeRadius, nodeRadius * 2, nodeRadius * 2 );
- graphicsContext.setColor( COLOR_EDGE );
- graphicsContext.drawOval( x - nodeRadius, y - nodeRadius, nodeRadius * 2, nodeRadius * 2 );
- graphicsContext.setColor( COLOR_LABEL_SHADOW );
- graphicsContext.drawString( node.toString(), x - ( node.toString().length() * 3 ) + 1, y - nodeRadius - 2 + 1 );
- graphicsContext.setColor( COLOR_LABEL );
- graphicsContext.drawString( node.toString(), x - ( node.toString().length() * 3 ), y - nodeRadius - 2 );
- }
- }
-
private int toImageX( Node node )
{
return (int) ( ( IMG_X - 50 ) * ( node.getX() - minX ) / ( maxX - minX ) ) + 25;
@@ -507,50 +422,6 @@ public class Graph implements java.io.Serializable
_caption = caption;
}
- public byte[] makeNextImage()
- {
- _frameCount++;
-
- Set<Node> nodes = getConnectedNodes();
-
- doLayout( nodes, 200 );
- calcBounds( nodes );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream( 100000 );
-
- try {
- drawImage( nodes, 0.1 );
- //ImageIO.write( targetImage, "png", baos );
- renderer.render( baos );
-
- writeGraph();
- return baos.toByteArray();
- } catch ( Exception e ) {
- System.out.println( "PieSpy has gone wibbly: " + e );
- e.printStackTrace();
- }
- return null;
- }
-
- // Serialize this Graph and write it to a File.
- public void writeGraph()
- {
- /*
- try {
- String strippedChannel = _label.toLowerCase().substring( 1 );
- File dir = new File( config.outputDirectory, strippedChannel );
- File file = new File( dir, strippedChannel + "-restore.dat" );
- ObjectOutputStream oos = new ObjectOutputStream( new FileOutputStream( file ) );
- oos.writeObject( SocialNetworkBot.VERSION );
- oos.writeObject( this );
- oos.flush();
- oos.close();
- } catch ( Exception e ) {
- // Do nothing?
- }
- */
- }
-
public Node getNode( String id )
{
return _nodes.get( new Node( id ) );