Skip to content

Commit

Permalink
Fix for issue #118 and #119
Browse files Browse the repository at this point in the history
Added another method that returns a BufferedImage renderToImage(w,h) as requested in issue #118 and (hopefully) fixed the signing issue #119
  • Loading branch information
HanSolo committed Dec 5, 2023
1 parent 92f882d commit e18cdbb
Show file tree
Hide file tree
Showing 33 changed files with 379 additions and 6 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ artifacts {
signing {
if (gpgkey && gpgpassphrase) {
useInMemoryPgpKeys(gpgkey, gpgpassphrase)
}

sign configurations.archives
sign publishing.publications
sign configurations.archives
sign publishing.publications
}
}

// Remove 'thirdPartyCompatibility' from JavaFX runtimeElements variant
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/ArcChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -549,6 +550,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(ArcChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(ArcChart.this, width, height);
}

private void validateData() {
connections.clear();
Map<PlotItem, Double> incoming = new HashMap<>(getItems().size());
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/BarChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -757,6 +758,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(BarChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(BarChart.this, width, height);
}

private void handleMouseEvents(final MouseEvent evt) {
final double x = evt.getX();
final double y = evt.getY();
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/BoxPlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import javafx.scene.paint.Color;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -599,6 +600,17 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(BoxPlot.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(BoxPlot.this, width, height);
}


// ******************** Layout ********************************************
@Override public String getUserAgentStylesheet() {
if (null == userAgentStyleSheet) { userAgentStyleSheet = BoxPlot.class.getResource("chart.css").toExternalForm(); }
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/BoxPlots.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import javafx.scene.paint.Color;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -619,6 +620,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(BoxPlots.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(BoxPlots.this, width, height);
}


// ******************** Layout ********************************************
private void resize() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/BubbleChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
Expand Down Expand Up @@ -205,6 +206,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(BubbleChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(BubbleChart.this, width, height);
}


// ******************** Layout ********************************************
private void update() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/BubbleGridChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -633,6 +634,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(BubbleGridChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(BubbleGridChart.this, width, height);
}

private void sort() {
sortCategoryX(getSortTopicX(), getSortOrderX());
sortCategoryY(getSortTopicY(), getSortOrderY());
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/CandleChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -481,6 +482,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(CandleChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(CandleChart.this, width, height);
}


// ******************** Layout ********************************************
@Override public String getUserAgentStylesheet() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/CircularPlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package eu.hansolo.fx.charts;

import java.awt.image.BufferedImage;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
Expand Down Expand Up @@ -475,6 +476,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(CircularPlot.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(CircularPlot.this, width, height);
}

protected void validateData() {
connections.clear();
Map<PlotItem, Double> incoming = new HashMap<>(getItems().size());
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/ComparisonBarChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -719,6 +720,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(ComparisonBarChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(ComparisonBarChart.this, width, height);
}


// ******************** Event Handling ************************************
public void addChartEvtObserver(final EvtType type, final EvtObserver<ChartEvt> observer) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/ComparisonRingChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -361,6 +362,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(ComparisonRingChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(ComparisonRingChart.this, width, height);
}


// ******************** Event Handling ************************************
public void addChartEvtObserver(final EvtType type, final EvtObserver<ChartEvt> observer) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/ConcentricRingChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
Expand Down Expand Up @@ -452,6 +453,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(ConcentricRingChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(ConcentricRingChart.this, width, height);
}


// ******************** Event Handling ************************************
public void addChartEvtObserver(final EvtType type, final EvtObserver<ChartEvt> observer) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/CoxcombChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -600,6 +601,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(CoxcombChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(CoxcombChart.this, width, height);
}

private void reorder(final Order ORDER) {
if (ORDER == Order.ASCENDING) {
sortItemsAscending();
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/CubeChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -455,6 +456,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(CubeChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(CubeChart.this, width, height);
}

private void wrapText(final GraphicsContext ctx, final String text, final double x, final double y, final double maxWidth, final double lineHeight, final int maxNoOfLines) {
double tx = x;
double ty = y;
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/MatrixPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Paint;

import java.awt.image.BufferedImage;


public class MatrixPane<T extends MatrixItem> extends Region implements ChartArea {
private static final double PREFERRED_WIDTH = 250;
Expand Down Expand Up @@ -337,6 +339,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(MatrixPane.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(MatrixPane.this, width, height);
}


// ******************** Draw Chart ****************************************
private void drawChart() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/eu/hansolo/fx/charts/NestedBarChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -345,6 +346,16 @@ public boolean renderToImage(final String filename, final int width, final int h
return Helper.renderToImage(NestedBarChart.this, width, height, filename);
}

/**
* Calling this method will render this chart/plot to a png given of the given width and height
* @param width The width of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @param height The height of the final image in pixels (if < 0 then 400 and if > 4096 then 4096)
* @return A BufferedImage of this chart in the given dimension
*/
public BufferedImage renderToImage(final int width, final int height) {
return Helper.renderToImage(NestedBarChart.this, width, height);
}

private void sortItems(final List<ChartItem> ITEMS, final Order ORDER) {
if (Order.ASCENDING == ORDER) {
Collections.sort(ITEMS, Comparator.comparingDouble(ChartItem::getValue));
Expand Down
Loading

0 comments on commit e18cdbb

Please sign in to comment.