History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/font/TextLabel.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/font/TextLabel.java+124−0
@@ -0,0 +1,124 @@
1+/*
2+ * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+/*
26+ *
27+ * (C) Copyright IBM Corp. 1998-2003 All Rights Reserved
28+ */
29+
30+package sun.font;
31+
32+import java.awt.Graphics2D;
33+import java.awt.Shape;
34+
35+import java.awt.geom.Rectangle2D;
36+
37+/**
38+ * A label.
39+ * Visual bounds is a rect that encompasses the entire rendered area.
40+ * Logical bounds is a rect that defines how to position this next
41+ * to other objects.
42+ * Align bounds is a rect that defines how to align this to margins.
43+ * it generally allows some overhang that logical bounds would prevent.
44+ */
45+public abstract class TextLabel {
46+
47+ /**
48+ * Return a rectangle that surrounds the text outline when this label is rendered at x, y.
49+ */
50+ public abstract Rectangle2D getVisualBounds(float x, float y);
51+
52+ /**
53+ * Return a rectangle that corresponds to the logical bounds of the text
54+ * when this label is rendered at x, y.
55+ * This rectangle is used when positioning text next to other text.
56+ */
57+ public abstract Rectangle2D getLogicalBounds(float x, float y);
58+
59+ /**
60+ * Return a rectangle that corresponds to the alignment bounds of the text
61+ * when this label is rendered at x, y. This rectangle is used when positioning text next
62+ * to a margin. It differs from the logical bounds in that it does not include leading or
63+ * trailing whitespace.
64+ */
65+ public abstract Rectangle2D getAlignBounds(float x, float y);
66+
67+ /**
68+ * Return a rectangle that corresponds to the logical bounds of the text, adjusted
69+ * to angle the leading and trailing edges by the italic angle.
70+ */
71+ public abstract Rectangle2D getItalicBounds(float x, float y);
72+
73+ /**
74+ * Return an outline of the characters in the label when rendered at x, y.
75+ */
76+ public abstract Shape getOutline(float x, float y);
77+
78+ /**
79+ * Render the label at x, y in the graphics.
80+ */
81+ public abstract void draw(Graphics2D g, float x, float y);
82+
83+ /**
84+ * A convenience method that returns the visual bounds when rendered at 0, 0.
85+ */
86+ public Rectangle2D getVisualBounds() {
87+ return getVisualBounds(0f, 0f);
88+ }
89+
90+ /**
91+ * A convenience method that returns the logical bounds when rendered at 0, 0.
92+ */
93+ public Rectangle2D getLogicalBounds() {
94+ return getLogicalBounds(0f, 0f);
95+ }
96+
97+ /**
98+ * A convenience method that returns the align bounds when rendered at 0, 0.
99+ */
100+ public Rectangle2D getAlignBounds() {
101+ return getAlignBounds(0f, 0f);
102+ }
103+
104+ /**
105+ * A convenience method that returns the italic bounds when rendered at 0, 0.
106+ */
107+ public Rectangle2D getItalicBounds() {
108+ return getItalicBounds(0f, 0f);
109+ }
110+
111+ /**
112+ * A convenience method that returns the outline when rendered at 0, 0.
113+ */
114+ public Shape getOutline() {
115+ return getOutline(0f, 0f);
116+ }
117+
118+ /**
119+ * A convenience method that renders the label at 0, 0.
120+ */
121+ public void draw(Graphics2D g) {
122+ draw(g, 0f, 0f);
123+ }
124+}