src/demo/share/jfc/Stylepad/Wonderland.java
author dholmes
Sun, 15 Sep 2019 21:00:15 -0400
changeset 58142 24df796eef3d
parent 50830 5500595d8ebf
permissions -rw-r--r--
8231033: Problemlist ReservedStackTest 8231034: ProblemList failing ThreadMXBean tests Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50830
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     1
/*
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     2
 *
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     3
 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     4
 *
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     5
 * Redistribution and use in source and binary forms, with or without
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     6
 * modification, are permitted provided that the following conditions
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     7
 * are met:
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     8
 *
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
     9
 *   - Redistributions of source code must retain the above copyright
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    10
 *     notice, this list of conditions and the following disclaimer.
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    11
 *
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    12
 *   - Redistributions in binary form must reproduce the above copyright
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    13
 *     notice, this list of conditions and the following disclaimer in the
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    14
 *     documentation and/or other materials provided with the distribution.
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    15
 *
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    16
 *   - Neither the name of Oracle nor the names of its
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    17
 *     contributors may be used to endorse or promote products derived
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    18
 *     from this software without specific prior written permission.
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    19
 *
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    21
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    22
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    23
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    24
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    25
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    26
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    27
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    28
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    29
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    30
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    31
 */
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    32
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    33
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    34
import java.awt.Color;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    35
import java.util.HashMap;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    36
import java.util.Locale;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    37
import java.util.MissingResourceException;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    38
import java.util.ResourceBundle;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    39
import javax.swing.Icon;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    40
import javax.swing.ImageIcon;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    41
import javax.swing.text.BadLocationException;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    42
import javax.swing.text.DefaultStyledDocument;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    43
import javax.swing.text.Style;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    44
import javax.swing.text.StyleConstants;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    45
import javax.swing.text.StyleContext;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    46
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    47
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    48
/**
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    49
 * hack to load attributed content
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    50
 */
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    51
public class Wonderland {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    52
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    53
    Wonderland(DefaultStyledDocument doc, StyleContext styles) {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    54
        this.doc = doc;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    55
        this.styles = styles;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    56
        runAttr = new HashMap<String, Style>();
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    57
    }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    58
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    59
    void loadDocument() {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    60
        createStyles();
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    61
        for (int i = 0; i < data.length; i++) {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    62
            Paragraph p = data[i];
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    63
            addParagraph(p);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    64
        }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    65
    }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    66
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    67
    void addParagraph(Paragraph p) {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    68
        try {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    69
            Style s = null;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    70
            for (int i = 0; i < p.data.length; i++) {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    71
                Run run = p.data[i];
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    72
                s = runAttr.get(run.attr);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    73
                doc.insertString(doc.getLength(), run.content, s);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    74
            }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    75
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    76
            // set logical style
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    77
            Style ls = styles.getStyle(p.logical);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    78
            doc.setLogicalStyle(doc.getLength() - 1, ls);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    79
            doc.insertString(doc.getLength(), "\n", null);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    80
        } catch (BadLocationException e) {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    81
            System.err.println("Internal error: " + e);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    82
        }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    83
    }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    84
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    85
    void createStyles() {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    86
        // no attributes defined
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    87
        Style s = styles.addStyle(null, null);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    88
        runAttr.put("none", s);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    89
        s = styles.addStyle(null, null);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    90
        StyleConstants.setItalic(s, true);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    91
        StyleConstants.setForeground(s, new Color(153, 153, 102));
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    92
        runAttr.put("cquote", s); // catepillar quote
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    93
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    94
        s = styles.addStyle(null, null);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    95
        StyleConstants.setItalic(s, true);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    96
        StyleConstants.setForeground(s, new Color(51, 102, 153));
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    97
        runAttr.put("aquote", s); // alice quote
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    98
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
    99
        try {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   100
            ResourceBundle resources = ResourceBundle.getBundle(
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   101
                    "resources.Stylepad",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   102
                    Locale.getDefault());
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   103
            s = styles.addStyle(null, null);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   104
            Icon alice =
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   105
                    new ImageIcon(getClass().
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   106
                    getResource(resources.getString("aliceGif")));
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   107
            StyleConstants.setIcon(s, alice);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   108
            runAttr.put("alice", s); // alice
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   109
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   110
            s = styles.addStyle(null, null);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   111
            Icon caterpillar =
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   112
                    new ImageIcon(getClass().
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   113
                    getResource(resources.getString("caterpillarGif")));
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   114
            StyleConstants.setIcon(s, caterpillar);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   115
            runAttr.put("caterpillar", s); // caterpillar
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   116
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   117
            s = styles.addStyle(null, null);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   118
            Icon hatter =
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   119
                    new ImageIcon(getClass().
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   120
                    getResource(resources.getString("hatterGif")));
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   121
            StyleConstants.setIcon(s, hatter);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   122
            runAttr.put("hatter", s); // hatter
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   123
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   124
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   125
        } catch (MissingResourceException mre) {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   126
            // can't display image
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   127
        }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   128
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   129
        Style def = styles.getStyle(StyleContext.DEFAULT_STYLE);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   130
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   131
        Style heading = styles.addStyle("heading", def);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   132
        StyleConstants.setFontFamily(heading, "SansSerif");
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   133
        StyleConstants.setBold(heading, true);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   134
        StyleConstants.setAlignment(heading, StyleConstants.ALIGN_CENTER);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   135
        StyleConstants.setSpaceAbove(heading, 10);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   136
        StyleConstants.setSpaceBelow(heading, 10);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   137
        StyleConstants.setFontSize(heading, 18);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   138
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   139
        // Title
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   140
        Style sty = styles.addStyle("title", heading);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   141
        StyleConstants.setFontSize(sty, 32);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   142
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   143
        // edition
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   144
        sty = styles.addStyle("edition", heading);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   145
        StyleConstants.setFontSize(sty, 16);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   146
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   147
        // author
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   148
        sty = styles.addStyle("author", heading);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   149
        StyleConstants.setItalic(sty, true);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   150
        StyleConstants.setSpaceBelow(sty, 25);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   151
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   152
        // subtitle
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   153
        sty = styles.addStyle("subtitle", heading);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   154
        StyleConstants.setSpaceBelow(sty, 35);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   155
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   156
        // normal
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   157
        sty = styles.addStyle("normal", def);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   158
        StyleConstants.setLeftIndent(sty, 10);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   159
        StyleConstants.setRightIndent(sty, 10);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   160
        StyleConstants.setFontFamily(sty, "SansSerif");
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   161
        StyleConstants.setFontSize(sty, 14);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   162
        StyleConstants.setSpaceAbove(sty, 4);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   163
        StyleConstants.setSpaceBelow(sty, 4);
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   164
    }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   165
    DefaultStyledDocument doc;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   166
    StyleContext styles;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   167
    HashMap<String, Style> runAttr;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   168
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   169
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   170
    static class Paragraph {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   171
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   172
        Paragraph(String logical, Run[] data) {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   173
            this.logical = logical;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   174
            this.data = data;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   175
        }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   176
        String logical;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   177
        Run[] data;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   178
    }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   179
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   180
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   181
    static class Run {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   182
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   183
        Run(String attr, String content) {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   184
            this.attr = attr;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   185
            this.content = content;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   186
        }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   187
        String attr;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   188
        String content;
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   189
    }
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   190
    Paragraph[] data = new Paragraph[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   191
        new Paragraph("title", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   192
            new Run("none", "ALICE'S ADVENTURES IN WONDERLAND")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   193
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   194
        new Paragraph("author", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   195
            new Run("none", "Lewis Carroll")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   196
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   197
        new Paragraph("heading", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   198
            new Run("alice", " ")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   199
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   200
        new Paragraph("edition", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   201
            new Run("none", "THE MILLENNIUM FULCRUM EDITION 3.0")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   202
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   203
        new Paragraph("heading", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   204
            new Run("none", "CHAPTER V")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   205
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   206
        new Paragraph("subtitle", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   207
            new Run("none", "Advice from a Caterpillar")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   208
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   209
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   210
            new Run("none", " "), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   211
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   212
            new Run("none",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   213
            "The Caterpillar and Alice looked at each other for some time in "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   214
                    + "silence:  at last the Caterpillar took the hookah out "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   215
                    + "of its mouth, and addressed her in a languid, sleepy "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   216
                    + "voice.")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   217
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   218
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   219
            new Run("cquote", "Who are YOU?  "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   220
            new Run("none", "said the Caterpillar.")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   221
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   222
        new Paragraph("normal",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   223
        new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   224
            new Run("none",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   225
            "This was not an encouraging opening for a conversation.  Alice "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   226
                    + "replied, rather shyly, "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   227
            new Run("aquote",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   228
            "I--I hardly know, sir, just at present--at least I know who I WAS "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   229
                    + "when I got up this morning, but I think I must have "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   230
                    + "been changed several times since then. "), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   231
        new Paragraph("heading", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   232
            new Run("caterpillar", " ")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   233
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   234
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   235
            new Run("cquote", "What do you mean by that? "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   236
            new Run("none", " said the Caterpillar sternly.  "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   237
            new Run("cquote", "Explain yourself!"), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   238
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   239
            new Run("aquote", "I can't explain MYSELF, I'm afraid, sir"),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   240
            new Run("none", " said Alice, "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   241
            new Run("aquote", "because I'm not myself, you see."), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   242
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   243
            new Run("cquote", "I don't see,"),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   244
            new Run("none", " said the Caterpillar."), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   245
        new Paragraph("normal",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   246
        new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   247
            new Run("aquote", "I'm afraid I can't put it more clearly,  "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   248
            new Run("none", "Alice replied very politely, "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   249
            new Run("aquote",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   250
            "for I can't understand it myself to begin with; and being so many "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   251
                    + "different sizes in a day is very confusing."), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   252
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   253
            new Run("cquote", "It isn't,  "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   254
            new Run("none", "said the Caterpillar.")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   255
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   256
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   257
            new Run("aquote", "Well, perhaps you haven't found it so yet,"),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   258
            new Run("none", " said Alice; "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   259
            new Run("aquote",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   260
            "but when you have to turn into a chrysalis--you will some day, "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   261
                    + "you know--and then after that into a butterfly, I "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   262
                    + "should think you'll feel it a little queer, won't you?")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   263
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   264
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   265
            new Run("cquote", "Not a bit, "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   266
            new Run("none", "said the Caterpillar.")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   267
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   268
        new Paragraph("normal",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   269
        new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   270
            new Run("aquote", "Well, perhaps your feelings may be different,"),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   271
            new Run("none", " said Alice; "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   272
            new Run("aquote", "all I know is, it would feel very queer to ME."),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   273
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   274
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   275
            new Run("cquote", "You!"),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   276
            new Run("none", " said the Caterpillar contemptuously.  "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   277
            new Run("cquote", "Who are YOU?"), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   278
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   279
            new Run("normal",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   280
            "Which brought them back again to the beginning of the "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   281
                    + "conversation.  Alice felt a little irritated at the "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   282
                    + "Caterpillar's making such VERY short remarks, and she "
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   283
                    + "drew herself up and said, very gravely, "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   284
            new Run("aquote",
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   285
            "I think, you ought to tell me who YOU are, first."), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   286
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   287
            new Run("cquote", "Why?  "),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   288
            new Run("none", "said the Caterpillar."), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   289
        new Paragraph("heading", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   290
            new Run("hatter", " ")
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   291
        }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   292
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   293
            new Run("none", " "), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   294
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   295
            new Run("none", " "), }),
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   296
        new Paragraph("normal", new Run[] {
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   297
            new Run("none", " "), })
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   298
    };
5500595d8ebf 8205136: Move StylePad demo to the open repository
prr
parents:
diff changeset
   299
}