Point2D startPoint = paint.getStartPoint();
Point2D endPoint = paint.getEndPoint();
float[] fractions = paint.getFractions();
Color[] colors = paint.getColors();
CycleMethodEnum cycleMethod = paint.getCycleMethod();
ColorSpaceEnum colorSpace = paint.getColorSpace();
AffineTransform transform = paint.getTransform();
StringBuffer fractionsRep = new StringBuffer();
if (fractions == null) {
fractionsRep.append("null");
} else {
String sep = "";
fractionsRep.append("new float[] {");
for (float fraction : fractions) {
fractionsRep.append(sep);
fractionsRep.append(fraction + "f");
sep = ",";
}
fractionsRep.append("}");
}
StringBuffer colorsRep = new StringBuffer();
if (fractions == null) {
colorsRep.append("null");
} else {
String sep = "";
colorsRep.append("new Color[] {");
for (Color color : colors) {
colorsRep.append(sep);
colorsRep.append("new Color(" + color.getRed() + ", "
+ color.getGreen() + ", " + color.getBlue()
+ ", " + color.getAlpha() + ")");
sep = ",";
}
colorsRep.append("}");
}
String cycleMethodRep = null;
if (cycleMethod == MultipleGradientPaint.NO_CYCLE) {
cycleMethodRep = "MultipleGradientPaint.CycleMethod.NO_CYCLE";
}
if (cycleMethod == MultipleGradientPaint.REFLECT) {
cycleMethodRep = "MultipleGradientPaint.CycleMethod.REFLECT";
}
if (cycleMethod == MultipleGradientPaint.REPEAT) {
cycleMethodRep = "MultipleGradientPaint.CycleMethod.REPEAT";
}
String colorSpaceRep = null;
if (colorSpace == MultipleGradientPaint.SRGB) {
colorSpaceRep = "MultipleGradientPaint.ColorSpaceType.SRGB";
}
if (colorSpace == MultipleGradientPaint.LINEAR_RGB) {
colorSpaceRep = "MultipleGradientPaint.ColorSpaceType.LINEAR_RGB";
}
double[] transfMatrix = new double[6];
transform.getMatrix(transfMatrix);
pw
.println("paint = new LinearGradientPaint(new Point2D.Double("
+ startPoint.getX()
+ ", "
+ startPoint.getY()
+ "), new Point2D.Double("
+ endPoint.getX()
+ ", "
+ endPoint.getY()
+ "), "
+ fractionsRep.toString()
+ ", "
+ colorsRep.toString()
+ ", "
+ cycleMethodRep
+ ", "
+ colorSpaceRep
+ ", new AffineTransform("
+ transfMatrix[0]
+ "f, "
+ transfMatrix[1]
+ "f, "
+ transfMatrix[2]
+ "f, "
+ transfMatrix[3]
+ "f, "
+ transfMatrix[4]
+ "f, "
+ transfMatrix[5] + "f));");
// offset(offset);
// pw.println("LinearGradientPaint");
// // offset(offset + 1);
// pw.println("START : " + paint.getStartPoint());
// // offset(offset + 1);
// pw.println("END : " + paint.getEndPoint());
// // offset(offset + 1);
// pw.println("FRACTIONS : " + paint.getFractions());
// // offset(offset + 1);
// pw.println("CYCLE_METHOD : " + paint.getCycleMethod());
// // offset(offset + 1);
// pw.println("COLOR_SPACE : " + paint.getColorSpace());
// // offset(offset + 1);
// pw.println("GRADIENT_TRANSFORM : " + paint.getTransform());
}
private void dumpPaint(PrintWriter pw, RadialGradientPaint paint,
int offset) {
// offset(offset);
Point2D centerPoint = paint.getCenterPoint();
float radius = paint.getRadius();
Point2D focusPoint = paint.getFocusPoint();
float[] fractions = paint.getFractions();
Color[] colors = paint.getColors();
CycleMethodEnum cycleMethod = paint.getCycleMethod();
ColorSpaceEnum colorSpace = paint.getColorSpace();
AffineTransform transform = paint.getTransform();
StringBuffer fractionsRep = new StringBuffer();
if (fractions == null) {
fractionsRep.append("null");