Various Small Updates To PNG Chart Export
- Creates PNG file filter - Adds new file filter to translation file - Makes Exported Chart's Width & Height as it is displayed - Changes Button From Print Icon to "Save As Image" text
This commit is contained in:
parent
d846094151
commit
c73a41071a
@ -96,6 +96,7 @@ FileHelper.ALL_DESIGNS_FILTER = All rocket designs (*.ork; *.rkt)
|
|||||||
FileHelper.OPENROCKET_DESIGN_FILTER = OpenRocket designs (*.ork)
|
FileHelper.OPENROCKET_DESIGN_FILTER = OpenRocket designs (*.ork)
|
||||||
FileHelper.ROCKSIM_DESIGN_FILTER = RockSim designs (*.rkt)
|
FileHelper.ROCKSIM_DESIGN_FILTER = RockSim designs (*.rkt)
|
||||||
FileHelper.OPEN_ROCKET_COMPONENT_FILTER = OpenRocket presets (*.orc)
|
FileHelper.OPEN_ROCKET_COMPONENT_FILTER = OpenRocket presets (*.orc)
|
||||||
|
FileHelper.PNG_FILTER = PNG image (*.png)
|
||||||
FileHelper.IMAGES = Image files
|
FileHelper.IMAGES = Image files
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,11 +117,11 @@ public class SimulationPlotDialog extends JDialog {
|
|||||||
panel.add(button, "gapleft rel");
|
panel.add(button, "gapleft rel");
|
||||||
|
|
||||||
//// Print chart button
|
//// Print chart button
|
||||||
button = new SelectColorButton(Icons.FILE_PRINT);
|
button = new SelectColorButton("Save As Image");
|
||||||
button.addActionListener(new ActionListener() {
|
button.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
doPngExport(jChart);
|
doPngExport(chartPanel,jChart);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(button, "gapleft rel");
|
panel.add(button, "gapleft rel");
|
||||||
@ -165,9 +165,10 @@ public class SimulationPlotDialog extends JDialog {
|
|||||||
GUIUtil.rememberWindowSize(this);
|
GUIUtil.rememberWindowSize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean doPngExport(JFreeChart chart){
|
private boolean doPngExport(ChartPanel chartPanel, JFreeChart chart){
|
||||||
JFileChooser chooser = new JFileChooser();
|
JFileChooser chooser = new JFileChooser();
|
||||||
chooser.setFileFilter(FileHelper.getImageFileFilter());
|
chooser.setAcceptAllFileFilterUsed(false);
|
||||||
|
chooser.setFileFilter(FileHelper.PNG_FILTER);
|
||||||
chooser.setCurrentDirectory(((SwingPreferences) Application.getPreferences()).getDefaultDirectory());
|
chooser.setCurrentDirectory(((SwingPreferences) Application.getPreferences()).getDefaultDirectory());
|
||||||
|
|
||||||
/* Ensures No Problems When Choosing File */
|
/* Ensures No Problems When Choosing File */
|
||||||
@ -185,7 +186,7 @@ public class SimulationPlotDialog extends JDialog {
|
|||||||
|
|
||||||
/* Uses JFreeChart Built In PNG Export Method */
|
/* Uses JFreeChart Built In PNG Export Method */
|
||||||
try{
|
try{
|
||||||
ChartUtilities.saveChartAsPNG(file, chart, 1000, 500);
|
ChartUtilities.saveChartAsPNG(file, chart, chartPanel.getWidth(), chartPanel.getHeight());
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,10 @@ public final class FileHelper {
|
|||||||
public static final FileFilter CSV_FILTER =
|
public static final FileFilter CSV_FILTER =
|
||||||
new SimpleFileFilter(trans.get("FileHelper.CSV_FILTER"), ".csv");
|
new SimpleFileFilter(trans.get("FileHelper.CSV_FILTER"), ".csv");
|
||||||
|
|
||||||
|
/** File filter for PNG files (*.png) */
|
||||||
|
public static final FileFilter PNG_FILTER =
|
||||||
|
new SimpleFileFilter(trans.get("FileHelper.PNG_FILTER"), ".png");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user