Java Code Examples for org.jfree.chart.util.SerialUtilities#writeAttributedString()

The following examples show how to use org.jfree.chart.util.SerialUtilities#writeAttributedString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SerialUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests the serialization of an {@link AttributedString}.
 */
public void testAttributedStringSerialization1() {
    AttributedString s1 = new AttributedString("");
    AttributedString s2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(buffer);
        SerialUtilities.writeAttributedString(s1, out);
        out.close();

        ByteArrayInputStream bais = new ByteArrayInputStream(
                buffer.toByteArray());
        ObjectInputStream in = new ObjectInputStream(bais);
        s2 = SerialUtilities.readAttributedString(in);
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertTrue(AttributedStringUtilities.equal(s1, s2));
}
 
Example 2
Source File: SerialUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests the serialization of an {@link AttributedString}.
 */
public void testAttributedStringSerialization2() {
    AttributedString s1 = new AttributedString("ABC");
    AttributedString s2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(buffer);
        SerialUtilities.writeAttributedString(s1, out);
        out.close();

        ByteArrayInputStream bais = new ByteArrayInputStream(
                buffer.toByteArray());
        ObjectInputStream in = new ObjectInputStream(bais);
        s2 = SerialUtilities.readAttributedString(in);
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertTrue(AttributedStringUtilities.equal(s1, s2));
}
 
Example 3
Source File: SerialUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests the serialization of an {@link AttributedString}.
 */
public void testAttributedStringSerialization3() {
    AttributedString s1 = new AttributedString("ABC");
    s1.addAttribute(TextAttribute.LANGUAGE, "English");
    AttributedString s2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(buffer);
        SerialUtilities.writeAttributedString(s1, out);
        out.close();

        ByteArrayInputStream bais = new ByteArrayInputStream(
                buffer.toByteArray());
        ObjectInputStream in = new ObjectInputStream(bais);
        s2 = SerialUtilities.readAttributedString(in);
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertTrue(AttributedStringUtilities.equal(s1, s2));
}
 
Example 4
Source File: LegendItem.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Provides serialization support.
 *
 * @param stream  the output stream (<code>null</code> not permitted).
 *
 * @throws IOException  if there is an I/O error.
 */
private void writeObject(ObjectOutputStream stream) throws IOException {
    stream.defaultWriteObject();
    SerialUtilities.writeAttributedString(this.attributedLabel, stream);
    SerialUtilities.writeShape(this.shape, stream);
    SerialUtilities.writePaint(this.fillPaint, stream);
    SerialUtilities.writeStroke(this.outlineStroke, stream);
    SerialUtilities.writePaint(this.outlinePaint, stream);
    SerialUtilities.writeShape(this.line, stream);
    SerialUtilities.writeStroke(this.lineStroke, stream);
    SerialUtilities.writePaint(this.linePaint, stream);
    SerialUtilities.writePaint(this.labelPaint, stream);
}
 
Example 5
Source File: LegendItem.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Provides serialization support.
 *
 * @param stream  the output stream (<code>null</code> not permitted).
 *
 * @throws IOException  if there is an I/O error.
 */
private void writeObject(ObjectOutputStream stream) throws IOException {
    stream.defaultWriteObject();
    SerialUtilities.writeAttributedString(this.attributedLabel, stream);
    SerialUtilities.writeShape(this.shape, stream);
    SerialUtilities.writePaint(this.fillPaint, stream);
    SerialUtilities.writeStroke(this.outlineStroke, stream);
    SerialUtilities.writePaint(this.outlinePaint, stream);
    SerialUtilities.writeShape(this.line, stream);
    SerialUtilities.writeStroke(this.lineStroke, stream);
    SerialUtilities.writePaint(this.linePaint, stream);
}