Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
XChart
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brady James Garvin
XChart
Commits
ee82986e
Commit
ee82986e
authored
10 years ago
by
Tim Molter
Browse files
Options
Downloads
Patches
Plain Diff
add "save as" for vector graphics (SVG, PDF, EPS) if VectorGraphics2D is found on classpath
parent
2e07f581
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
xchart/src/main/java/com/xeiam/xchart/XChartPanel.java
+19
-0
19 additions, 0 deletions
xchart/src/main/java/com/xeiam/xchart/XChartPanel.java
with
19 additions
and
0 deletions
xchart/src/main/java/com/xeiam/xchart/XChartPanel.java
+
19
−
0
View file @
ee82986e
...
...
@@ -39,6 +39,7 @@ import javax.swing.KeyStroke;
import
javax.swing.filechooser.FileFilter
;
import
com.xeiam.xchart.BitmapEncoder.BitmapFormat
;
import
com.xeiam.xchart.VectorGraphicsEncoder.VectorGraphicsFormat
;
/**
* A Swing JPanel that contains a Chart
...
...
@@ -118,6 +119,18 @@ public class XChartPanel extends JPanel {
fileChooser
.
addChoosableFileFilter
(
pngFileFilter
);
fileChooser
.
addChoosableFileFilter
(
new
SuffixSaveFilter
(
"bmp"
));
fileChooser
.
addChoosableFileFilter
(
new
SuffixSaveFilter
(
"gif"
));
// VectorGraphics2D is optional, so if it's on the classpath, allow saving charts as vector graphic
try
{
Class
.
forName
(
"de.erichseifert.vectorgraphics2d.VectorGraphics2D"
);
// it exists on the classpath
fileChooser
.
addChoosableFileFilter
(
new
SuffixSaveFilter
(
"svg"
));
fileChooser
.
addChoosableFileFilter
(
new
SuffixSaveFilter
(
"eps"
));
fileChooser
.
addChoosableFileFilter
(
new
SuffixSaveFilter
(
"pdf"
));
}
catch
(
ClassNotFoundException
e
)
{
// it does not exist on the classpath
}
fileChooser
.
setAcceptAllFileFilterUsed
(
false
);
fileChooser
.
setFileFilter
(
pngFileFilter
);
...
...
@@ -138,6 +151,12 @@ public class XChartPanel extends JPanel {
BitmapEncoder
.
saveBitmap
(
chart
,
theFileToSave
.
getCanonicalPath
().
toString
(),
BitmapFormat
.
BMP
);
}
else
if
(
fileChooser
.
getFileFilter
().
getDescription
().
equals
(
"*.gif,*.GIF"
))
{
BitmapEncoder
.
saveBitmap
(
chart
,
theFileToSave
.
getCanonicalPath
().
toString
(),
BitmapFormat
.
GIF
);
}
else
if
(
fileChooser
.
getFileFilter
().
getDescription
().
equals
(
"*.svg,*.SVG"
))
{
VectorGraphicsEncoder
.
saveVectorGraphic
(
chart
,
theFileToSave
.
getCanonicalPath
().
toString
(),
VectorGraphicsFormat
.
SVG
);
}
else
if
(
fileChooser
.
getFileFilter
().
getDescription
().
equals
(
"*.eps,*.EPS"
))
{
VectorGraphicsEncoder
.
saveVectorGraphic
(
chart
,
theFileToSave
.
getCanonicalPath
().
toString
(),
VectorGraphicsFormat
.
EPS
);
}
else
if
(
fileChooser
.
getFileFilter
().
getDescription
().
equals
(
"*.pdf,*.PDF"
))
{
VectorGraphicsEncoder
.
saveVectorGraphic
(
chart
,
theFileToSave
.
getCanonicalPath
().
toString
(),
VectorGraphicsFormat
.
PDF
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment