Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1446824 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Sandro Martini
committed
Feb 16, 2013
1 parent
d2b2427
commit feb0b8b
Showing
30 changed files
with
955 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>examples</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.scala-ide.sdt.core.scalabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.scala-ide.sdt.core.scalanature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>examples</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// README for org.apache.pivot.examples.scripting Samples | ||
// | ||
|
||
In this package there are some Groovy sources and even some Scala sources, but in our ant builds they are not compiled. | ||
To run those examples from an IDE (like Eclipse), you must enable support for those languages for the project containing them (examples). | ||
|
||
Note that in case of problems, for example a configured Nature for that project but the related Plugin is not installed, | ||
it will not be possible to run even Java examples because nothing in that project will be compiled. |
118 changes: 118 additions & 0 deletions
118
tests/src/org/apache/pivot/tests/LabelAntialiasTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.pivot.tests; | ||
|
||
import java.awt.Color; | ||
import java.awt.Font; | ||
import java.awt.GraphicsEnvironment; | ||
import java.awt.Toolkit; | ||
import java.awt.geom.AffineTransform; | ||
|
||
import org.apache.pivot.collections.Map; | ||
import org.apache.pivot.wtk.Application; | ||
import org.apache.pivot.wtk.DesktopApplicationContext; | ||
import org.apache.pivot.wtk.Display; | ||
import org.apache.pivot.wtk.HorizontalAlignment; | ||
import org.apache.pivot.wtk.Label; | ||
import org.apache.pivot.wtk.VerticalAlignment; | ||
import org.apache.pivot.wtk.Window; | ||
|
||
public class LabelAntialiasTest extends Application.Adapter { | ||
private Window window = null; | ||
|
||
private Label buildLabel(double rotation) { | ||
Label label = new Label(); | ||
|
||
Font font = new Font("Arial", Font.BOLD, 64); | ||
|
||
AffineTransform fontAT = new AffineTransform(); | ||
// Derive a new font using a rotation transform | ||
fontAT.rotate(rotation * java.lang.Math.PI / 180.0d); | ||
Font fontDerived = font.deriveFont(fontAT); | ||
|
||
label.setText("Hello at " + rotation + " degree."); | ||
label.getStyles().put("color", Color.RED); | ||
label.getStyles().put("font", fontDerived); | ||
label.getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER); | ||
label.getStyles().put("verticalAlignment", VerticalAlignment.TOP); | ||
|
||
return label; | ||
} | ||
|
||
/** | ||
* Write to console some details of Desktop Hints, for Font Rendering. | ||
* | ||
* @see org.apache.pivot.wtk.Platform#initializeFontRenderContext | ||
*/ | ||
private void showFontDesktopHints() { | ||
System.out.println("Show Font Desktop Hints:"); | ||
|
||
Toolkit toolkit = Toolkit.getDefaultToolkit(); | ||
java.util.Map<?, ?> fontDesktopHints = | ||
(java.util.Map<?, ?>)toolkit.getDesktopProperty("awt.font.desktophints"); | ||
|
||
System.out.println(fontDesktopHints); | ||
} | ||
|
||
/** | ||
* Write to console the list of Font families found in the System. | ||
*/ | ||
private void showFontFamilies() { | ||
System.out.println("Show Font Families:"); | ||
|
||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | ||
String []fontFamilies = ge.getAvailableFontFamilyNames(); | ||
int fontFamiliesNumber = fontFamilies.length; | ||
StringBuffer fontFamilyNames = new StringBuffer(1024); | ||
for (int i=0; i < fontFamiliesNumber; i++) { | ||
if (i > 0) { | ||
fontFamilyNames.append(", "); | ||
} | ||
fontFamilyNames.append(fontFamilies[i]); | ||
} | ||
System.out.println(fontFamilyNames); | ||
} | ||
|
||
@Override | ||
public void startup(Display display, Map<String, String> properties) { | ||
window = new Window(); | ||
|
||
showFontDesktopHints(); | ||
showFontFamilies(); | ||
|
||
Label label = buildLabel(45); | ||
window.setContent(label); | ||
|
||
window.setTitle("Label Antialiasing Test"); | ||
window.setMaximized(true); | ||
window.open(display); | ||
} | ||
|
||
@Override | ||
public boolean shutdown(boolean optional) { | ||
if (window != null) { | ||
window.close(); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public static void main(String[] args) { | ||
DesktopApplicationContext.main(LabelAntialiasTest.class, args); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to you under the Apache License, | ||
Version 2.0 (the "License"); you may not use this file except in | ||
compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<Window title="Pivot-880" maximized="true" | ||
bxml:id="window" | ||
xmlns:bxml="http://pivot.apache.org/bxml" | ||
xmlns="org.apache.pivot.wtk" | ||
> | ||
|
||
<Form> | ||
<Form.Section> | ||
<TextInput bxml:id="textInput" text="${textArea.text}"/> | ||
<Border> | ||
<FillPane minimumWidth="300" minimumHeight="100"> | ||
<TextArea bxml:id="textArea" text="${textInput.text}"/> | ||
</FillPane> | ||
</Border> | ||
</Form.Section> | ||
</Form> | ||
|
||
</Window> |
Oops, something went wrong.