1 /*
2 *
3 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of Oracle nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
140 add(surface);
141 }
142 revalidate();
143 repaint();
144 }
145 });
146 }
147
148 public void start() {
149 if (!doTable) {
150 surface.start();
151 }
152 }
153
154 public void stop() {
155 if (!doTable) {
156 surface.stop();
157 }
158 }
159
160 public static void main(String argv[]) {
161 final Intro intro = new Intro();
162 WindowListener l = new WindowAdapter() {
163
164 @Override
165 public void windowClosing(WindowEvent e) {
166 System.exit(0);
167 }
168
169 @Override
170 public void windowDeiconified(WindowEvent e) {
171 intro.start();
172 }
173
174 @Override
175 public void windowIconified(WindowEvent e) {
176 intro.stop();
177 }
178 };
179 JFrame f = new JFrame("Java2D(TM) Demo - Intro");
180 f.addWindowListener(l);
480 public void render(int w, int h, Graphics2D g2);
481
482 public int getBegin();
483
484 public int getEnd();
485 }
486
487
488 /**
489 * Director is the holder of the scenes, their names & pause amounts
490 * between scenes.
491 */
492 static class Director extends ArrayList<Scene> {
493
494 GradientPaint gp = new GradientPaint(0, 40, myBlue, 38, 2, myBlack);
495 Font f1 = new Font(Font.SERIF, Font.PLAIN, 200);
496 Font f2 = new Font(Font.SERIF, Font.PLAIN, 120);
497 Font f3 = new Font(Font.SERIF, Font.PLAIN, 72);
498
499 public Director(Surface surf) {
500 Object partsInfo[][][] = {
501 { { "J - scale text on gradient", "0" },
502 { new GpE(GpE.BURI, myBlack, myBlue, 0, 20),
503 new TxE("J", f1, TxE.SCI, myYellow, 2, 20) } },
504 { { "2 - scale & rotate text on gradient", "0" },
505 { new GpE(GpE.BURI, myBlue, myBlack, 0, 22),
506 new TxE("2", f1, TxE.RI | TxE.SCI, myYellow, 2, 22) } },
507 { { "D - scale text on gradient", "0" },
508 { new GpE(GpE.BURI, myBlack, myBlue, 0, 20),
509 new TxE("D", f1, TxE.SCI, myYellow, 2, 20) } },
510 { { "J2D demo - scale & rotate text on gradient", "1000" },
511 { new GpE(GpE.SIH, myBlue, myBlack, 0, 40),
512 new TxE("J2D demo", f2, TxE.RI | TxE.SCI, myYellow, 0, 40) } },
513 { { "Previous scene dither dissolve out", "0" },
514 { new DdE(0, 20, 1, surf) } },
515 { { "Graphics Features", "999" },
516 { new Temp(Temp.RECT, null, 0, 15),
517 new Temp(Temp.IMG, surf.duke, 2, 15),
518 new Temp(Temp.RNA | Temp.INA, surf.duke, 16, 130),
519 new Features(Features.GRAPHICS, 16, 130, surf) } },
520 { { "J2D demo - texture text on gradient", "1000" },
660 static final int DEC = 2;
661 static final int R = 4; // rotate
662 static final int RI = R | INC;
663 static final int RD = R | DEC;
664 static final int SC = 8; // scale
665 static final int SCI = SC | INC;
666 static final int SCD = SC | DEC;
667 static final int SCX = 16; // scale invert x
668 static final int SCXI = SCX | SC | INC;
669 static final int SCXD = SCX | SC | DEC;
670 static final int SCY = 32; // scale invert y
671 static final int SCYI = SCY | SC | INC;
672 static final int SCYD = SCY | SC | DEC;
673 static final int AC = 64; // AlphaComposite
674 static final int CLIP = 128; // Clipping
675 static final int NOP = 512; // No Paint
676 private int beginning, ending;
677 private int type;
678 private double rIncr, sIncr;
679 private double sx, sy, rotate;
680 private Shape shapes[], txShapes[];
681 private int sw;
682 private int numRev;
683 private Paint paint;
684
685 public TxE(String text,
686 Font font,
687 int type,
688 Paint paint,
689 int beg,
690 int end) {
691 this.type = type;
692 this.paint = paint;
693 this.beginning = beg;
694 this.ending = end;
695
696 setIncrements(2);
697
698 char[] chars = text.toCharArray();
699 shapes = new Shape[chars.length];
700 txShapes = new Shape[chars.length];
1593 @Override
1594 public int getEnd() {
1595 return ending;
1596 }
1597 } // End Temp class
1598
1599
1600 /**
1601 * Features of Java2D(TM). Single character advancement effect.
1602 */
1603 static class Features implements Part {
1604
1605 static final int GRAPHICS = 0;
1606 static final int TEXT = 1;
1607 static final int IMAGES = 2;
1608 static final int COLOR = 3;
1609 static final Font font1 = new Font(Font.SERIF, Font.BOLD, 38);
1610 static final Font font2 = new Font(Font.SERIF, Font.PLAIN, 24);
1611 private final FontMetrics fm1;
1612 private final FontMetrics fm2;
1613 private static final String table[][] = { { "Graphics", "Antialiased rendering",
1614 "Bezier paths",
1615 "Transforms", "Compositing", "Stroking parameters" },
1616 { "Text", "Extended font support",
1617 "Advanced text layout", "Dynamic font loading",
1618 "AttributeSets for font customization" },
1619 { "Images", "Flexible image layouts",
1620 "Extended imaging operations",
1621 " Convolutions, Lookup Tables",
1622 "RenderableImage interface" },
1623 { "Color", "ICC profile support", "Color conversion",
1624 "Arbitrary color spaces" } };
1625 private String list[];
1626 private int beginning, ending;
1627 private int strH;
1628 private int endIndex, listIndex;
1629 private List<String> v = new ArrayList<String>();
1630
1631 public Features(int type, int beg, int end, Surface surf) {
1632 list = table[type];
1633 this.beginning = beg;
1634 this.ending = end;
1635 fm1 = surf.getMetrics(font1);
1636 fm2 = surf.getMetrics(font2);
1637 }
1638
1639 @Override
1640 public void reset(int w, int h) {
1641 strH = (fm2.getAscent() + fm2.getDescent());
1642 endIndex = 1;
1643 listIndex = 0;
1644 v.clear();
1645 v.add(list[listIndex].substring(0, endIndex));
1670 }
1671 }
1672
1673 @Override
1674 public int getBegin() {
1675 return beginning;
1676 }
1677
1678 @Override
1679 public int getEnd() {
1680 return ending;
1681 }
1682 } // End Features class
1683
1684
1685 /**
1686 * Scrolling text of Java2D(TM) contributors.
1687 */
1688 static class Contributors implements Part {
1689
1690 private static final String members[] = {
1691 "Brian Lichtenwalter", "Jeannette Hung",
1692 "Thanh Nguyen", "Jim Graham", "Jerry Evans",
1693 "John Raley", "Michael Peirce", "Robert Kim",
1694 "Jennifer Ball", "Deborah Adair", "Paul Charlton",
1695 "Dmitry Feld", "Gregory Stone", "Richard Blanchard",
1696 "Link Perry", "Phil Race", "Vincent Hardy",
1697 "Parry Kejriwal", "Doug Felt", "Rekha Rangarajan",
1698 "Paula Patel", "Michael Bundschuh", "Joe Warzecha",
1699 "Joey Beheler", "Aastha Bhardwaj", "Daniel Rice",
1700 "Chris Campbell", "Shinsuke Fukuda", "Dmitri Trembovetski",
1701 "Chet Haase", "Jennifer Godinez", "Nicholas Talian",
1702 "Raul Vera", "Ankit Patel", "Ilya Bagrak",
1703 "Praveen Mohan", "Rakesh Menon"
1704 };
1705 private static final Font font = new Font(Font.SERIF, Font.PLAIN, 26);
1706 private final FontMetrics fm;
1707 private int beginning, ending;
1708 private int nStrs, strH, index, yh, height;
1709 private List<String> v = new ArrayList<String>();
1710 private List<String> cast =
|
1 /*
2 *
3 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of Oracle nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
140 add(surface);
141 }
142 revalidate();
143 repaint();
144 }
145 });
146 }
147
148 public void start() {
149 if (!doTable) {
150 surface.start();
151 }
152 }
153
154 public void stop() {
155 if (!doTable) {
156 surface.stop();
157 }
158 }
159
160 public static void main(String[] argv) {
161 final Intro intro = new Intro();
162 WindowListener l = new WindowAdapter() {
163
164 @Override
165 public void windowClosing(WindowEvent e) {
166 System.exit(0);
167 }
168
169 @Override
170 public void windowDeiconified(WindowEvent e) {
171 intro.start();
172 }
173
174 @Override
175 public void windowIconified(WindowEvent e) {
176 intro.stop();
177 }
178 };
179 JFrame f = new JFrame("Java2D(TM) Demo - Intro");
180 f.addWindowListener(l);
480 public void render(int w, int h, Graphics2D g2);
481
482 public int getBegin();
483
484 public int getEnd();
485 }
486
487
488 /**
489 * Director is the holder of the scenes, their names & pause amounts
490 * between scenes.
491 */
492 static class Director extends ArrayList<Scene> {
493
494 GradientPaint gp = new GradientPaint(0, 40, myBlue, 38, 2, myBlack);
495 Font f1 = new Font(Font.SERIF, Font.PLAIN, 200);
496 Font f2 = new Font(Font.SERIF, Font.PLAIN, 120);
497 Font f3 = new Font(Font.SERIF, Font.PLAIN, 72);
498
499 public Director(Surface surf) {
500 Object[][][] partsInfo = {
501 { { "J - scale text on gradient", "0" },
502 { new GpE(GpE.BURI, myBlack, myBlue, 0, 20),
503 new TxE("J", f1, TxE.SCI, myYellow, 2, 20) } },
504 { { "2 - scale & rotate text on gradient", "0" },
505 { new GpE(GpE.BURI, myBlue, myBlack, 0, 22),
506 new TxE("2", f1, TxE.RI | TxE.SCI, myYellow, 2, 22) } },
507 { { "D - scale text on gradient", "0" },
508 { new GpE(GpE.BURI, myBlack, myBlue, 0, 20),
509 new TxE("D", f1, TxE.SCI, myYellow, 2, 20) } },
510 { { "J2D demo - scale & rotate text on gradient", "1000" },
511 { new GpE(GpE.SIH, myBlue, myBlack, 0, 40),
512 new TxE("J2D demo", f2, TxE.RI | TxE.SCI, myYellow, 0, 40) } },
513 { { "Previous scene dither dissolve out", "0" },
514 { new DdE(0, 20, 1, surf) } },
515 { { "Graphics Features", "999" },
516 { new Temp(Temp.RECT, null, 0, 15),
517 new Temp(Temp.IMG, surf.duke, 2, 15),
518 new Temp(Temp.RNA | Temp.INA, surf.duke, 16, 130),
519 new Features(Features.GRAPHICS, 16, 130, surf) } },
520 { { "J2D demo - texture text on gradient", "1000" },
660 static final int DEC = 2;
661 static final int R = 4; // rotate
662 static final int RI = R | INC;
663 static final int RD = R | DEC;
664 static final int SC = 8; // scale
665 static final int SCI = SC | INC;
666 static final int SCD = SC | DEC;
667 static final int SCX = 16; // scale invert x
668 static final int SCXI = SCX | SC | INC;
669 static final int SCXD = SCX | SC | DEC;
670 static final int SCY = 32; // scale invert y
671 static final int SCYI = SCY | SC | INC;
672 static final int SCYD = SCY | SC | DEC;
673 static final int AC = 64; // AlphaComposite
674 static final int CLIP = 128; // Clipping
675 static final int NOP = 512; // No Paint
676 private int beginning, ending;
677 private int type;
678 private double rIncr, sIncr;
679 private double sx, sy, rotate;
680 private Shape[] shapes; private Shape[] txShapes;
681 private int sw;
682 private int numRev;
683 private Paint paint;
684
685 public TxE(String text,
686 Font font,
687 int type,
688 Paint paint,
689 int beg,
690 int end) {
691 this.type = type;
692 this.paint = paint;
693 this.beginning = beg;
694 this.ending = end;
695
696 setIncrements(2);
697
698 char[] chars = text.toCharArray();
699 shapes = new Shape[chars.length];
700 txShapes = new Shape[chars.length];
1593 @Override
1594 public int getEnd() {
1595 return ending;
1596 }
1597 } // End Temp class
1598
1599
1600 /**
1601 * Features of Java2D(TM). Single character advancement effect.
1602 */
1603 static class Features implements Part {
1604
1605 static final int GRAPHICS = 0;
1606 static final int TEXT = 1;
1607 static final int IMAGES = 2;
1608 static final int COLOR = 3;
1609 static final Font font1 = new Font(Font.SERIF, Font.BOLD, 38);
1610 static final Font font2 = new Font(Font.SERIF, Font.PLAIN, 24);
1611 private final FontMetrics fm1;
1612 private final FontMetrics fm2;
1613 private static final String[][] table = { { "Graphics", "Antialiased rendering",
1614 "Bezier paths",
1615 "Transforms", "Compositing", "Stroking parameters" },
1616 { "Text", "Extended font support",
1617 "Advanced text layout", "Dynamic font loading",
1618 "AttributeSets for font customization" },
1619 { "Images", "Flexible image layouts",
1620 "Extended imaging operations",
1621 " Convolutions, Lookup Tables",
1622 "RenderableImage interface" },
1623 { "Color", "ICC profile support", "Color conversion",
1624 "Arbitrary color spaces" } };
1625 private String[] list;
1626 private int beginning, ending;
1627 private int strH;
1628 private int endIndex, listIndex;
1629 private List<String> v = new ArrayList<String>();
1630
1631 public Features(int type, int beg, int end, Surface surf) {
1632 list = table[type];
1633 this.beginning = beg;
1634 this.ending = end;
1635 fm1 = surf.getMetrics(font1);
1636 fm2 = surf.getMetrics(font2);
1637 }
1638
1639 @Override
1640 public void reset(int w, int h) {
1641 strH = (fm2.getAscent() + fm2.getDescent());
1642 endIndex = 1;
1643 listIndex = 0;
1644 v.clear();
1645 v.add(list[listIndex].substring(0, endIndex));
1670 }
1671 }
1672
1673 @Override
1674 public int getBegin() {
1675 return beginning;
1676 }
1677
1678 @Override
1679 public int getEnd() {
1680 return ending;
1681 }
1682 } // End Features class
1683
1684
1685 /**
1686 * Scrolling text of Java2D(TM) contributors.
1687 */
1688 static class Contributors implements Part {
1689
1690 private static final String[] members = {
1691 "Brian Lichtenwalter", "Jeannette Hung",
1692 "Thanh Nguyen", "Jim Graham", "Jerry Evans",
1693 "John Raley", "Michael Peirce", "Robert Kim",
1694 "Jennifer Ball", "Deborah Adair", "Paul Charlton",
1695 "Dmitry Feld", "Gregory Stone", "Richard Blanchard",
1696 "Link Perry", "Phil Race", "Vincent Hardy",
1697 "Parry Kejriwal", "Doug Felt", "Rekha Rangarajan",
1698 "Paula Patel", "Michael Bundschuh", "Joe Warzecha",
1699 "Joey Beheler", "Aastha Bhardwaj", "Daniel Rice",
1700 "Chris Campbell", "Shinsuke Fukuda", "Dmitri Trembovetski",
1701 "Chet Haase", "Jennifer Godinez", "Nicholas Talian",
1702 "Raul Vera", "Ankit Patel", "Ilya Bagrak",
1703 "Praveen Mohan", "Rakesh Menon"
1704 };
1705 private static final Font font = new Font(Font.SERIF, Font.PLAIN, 26);
1706 private final FontMetrics fm;
1707 private int beginning, ending;
1708 private int nStrs, strH, index, yh, height;
1709 private List<String> v = new ArrayList<String>();
1710 private List<String> cast =
|