Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.BasicStroke;
import java.awt.Stroke;

import java.io.IOException;

import java.io.ObjectOutputStream;

import java.io.Serializable;

public class Main {
    public static void writeStroke(Stroke aStroke, ObjectOutputStream out) throws IOException {
        if (aStroke instanceof Serializable) {
            out.writeBoolean(true);
            out.writeBoolean(true);
            out.writeObject(aStroke);
        } else if (aStroke instanceof BasicStroke) {
            out.writeBoolean(true);
            out.writeBoolean(false);
            BasicStroke s = (BasicStroke) aStroke;

            float[] dash = s.getDashArray();

            if (dash == null) {
                out.write(0);
            } else {
                out.write(dash.length);
                for (int i = 0; i < dash.length; i++) {
                    out.writeFloat(dash[i]);
                }
            }

            out.writeFloat(s.getLineWidth());
            out.writeInt(s.getEndCap());
            out.writeInt(s.getLineJoin());
            out.writeFloat(s.getMiterLimit());
            out.writeFloat(s.getDashPhase());
        } else {
            out.writeBoolean(false);
        }
    }
}