Skip to content

Commit

Permalink
restructed to use git and maven
Browse files Browse the repository at this point in the history
  • Loading branch information
pago committed Apr 21, 2011
0 parents commit c8f09f1
Show file tree
Hide file tree
Showing 76 changed files with 7,773 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.DS_Store
target/
.idea/
17 changes: 17 additions & 0 deletions pgslookandfeel.iml
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

12 changes: 12 additions & 0 deletions pom.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.pagosoft</groupId>
<artifactId>pgslookandfeel</artifactId>
<version>1.1.2</version>
<packaging>jar</packaging>

</project>
76 changes: 76 additions & 0 deletions src/main/java/com/pagosoft/OS.java
@@ -0,0 +1,76 @@
/*
* Copyright 2005 Patrick Gotthardt
*
* Licensed 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 com.pagosoft;

import java.io.File;

public class OS {
private static boolean isMacOsX = false;
private static boolean isWindows = false;
private static boolean isWindowsXP = false;
private static boolean isUnix = false;

private static boolean isJava14 = false;
private static boolean isJava15 = false;

static {
// Current Java version:
String javaVersion = System.getProperty("java.version");
isJava14 = (javaVersion.compareTo("1.4") >= 0);
isJava15 = (javaVersion.compareTo("1.5") >= 0);

/*if(System.getProperty("mrj.version") != null) {
isMacOsX = true;
} else {*/
String os = System.getProperty("os.name").toLowerCase();
// http://developer.apple.com/technotes/tn2002/tn2110.html#PARTONE
if(os.startsWith("mac os x")) {
isMacOsX = true;
} else {
isWindows = os.indexOf("windows") != -1;
if(isWindows) {
isWindowsXP = os.indexOf("windows xp") != -1;
} else {
isUnix = File.separatorChar == '/';
}
}
//}
}

public static boolean isWindows() {
return isWindows;
}

public static boolean isWindowsXP() {
return isWindowsXP;
}

public static boolean isMacOsX() {
return isMacOsX;
}

public static boolean isUnix() {
return isUnix;
}

public static boolean isJava15() {
return isJava15;
}

public static boolean isJava14() {
return isJava14;
}
}
257 changes: 257 additions & 0 deletions src/main/java/com/pagosoft/plaf/PgsBorders.java
@@ -0,0 +1,257 @@
/*
* Copyright 2005 Patrick Gotthardt
*
* Licensed 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 com.pagosoft.plaf;

import javax.swing.*;
import javax.swing.text.JTextComponent;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import java.awt.*;

public class PgsBorders {
public static class Generic extends AbstractBorder implements UIResource {
private Insets insets;
private Color color;
public Generic(Insets insets, Color color) {
this.insets = insets;
this.color = color;
}

public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(color);
if(insets.left != 0) {
g.fillRect(x, y, x+insets.left, y+height);
}
if(insets.right != 0) {
g.fillRect(x+width-insets.right, y, x+width, y+height);
}
if(insets.top != 0) {
g.fillRect(x, y, x+width, x+insets.top);
}
if(insets.bottom != 0) {
g.fillRect(x, y+height-insets.bottom, x+width, y+height);
}
}

public Insets getBorderInsets(Component c) {
return insets;
}

public Insets getBorderInsets(Component c, Insets insets) {
return insets;
}
}

private static Border buttonBorder;

public static Border getButtonBorder() {
if (buttonBorder == null) {
buttonBorder = new BorderUIResource.CompoundBorderUIResource(
new ButtonBorder(),
new BasicBorders.MarginBorder());
}
return buttonBorder;
}

private static class ButtonBorder extends AbstractBorder implements UIResource {
protected static final Insets INSETS = new Insets(3, 4, 3, 4);
protected static final Insets NO_INSETS = new Insets(0, 0, 0, 0);

public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
AbstractButton button = (AbstractButton) c;
ButtonModel model = button.getModel();

if (model.isEnabled()) {
if (model.isRollover() && PlafOptions.isPaintRolloverButtonBorder()) {
PgsUtils.drawRolloverButtonBorder(g, x, y, w, h);
} else {
PgsUtils.drawButtonBorder(g, x, y, w, h);
}
} else { // disabled state
PgsUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
}
}

public Insets getBorderInsets(Component c) {
if (((AbstractButton) c).isBorderPainted()) {
return INSETS;
}
return NO_INSETS;
}

public Insets getBorderInsets(Component c, Insets newInsets) {
if (((AbstractButton) c).isBorderPainted()) {
return getBorderInsets(c, newInsets, INSETS);
}
return getBorderInsets(c, newInsets, NO_INSETS);
}

public Insets getBorderInsets(Component c, Insets newInsets, Insets oldInsets) {
newInsets.top = oldInsets.top;
newInsets.left = oldInsets.left;
newInsets.bottom = oldInsets.bottom;
newInsets.right = oldInsets.right;
return newInsets;
}
}

private static Border textFieldBorder;

public static Border getTextFieldBorder() {
if (textFieldBorder == null) {
textFieldBorder = new BorderUIResource.CompoundBorderUIResource(
new TextFieldBorder(),
new BasicBorders.MarginBorder());
}
return textFieldBorder;
}

private static class TextFieldBorder extends AbstractBorder {
private static final Insets INSETS = new Insets(1, 1, 1, 1);

//private static final Insets INSETS = new Insets(0, 0, 0, 0);
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if (c.isEnabled()) {
//PgsUtils.drawButtonBorder(g, x, y, w, h);
boolean isEditable = (c instanceof JTextComponent && ((JTextComponent)c).isEditable()) || (c instanceof JComboBox && ((JComboBox)c).isEditable());
boolean hasFocus = c.hasFocus();
if(c instanceof JComboBox) {
JComboBox comboBox = ((JComboBox) c);
hasFocus = comboBox.isEditable() && comboBox.getEditor().getEditorComponent().hasFocus();
}
PgsUtils.drawButtonBorder(g, x, y, w - 1, h - 1, 2, 2, hasFocus && isEditable ? PgsLookAndFeel.getPrimaryControlDarkShadow() : PgsLookAndFeel.getControlDarkShadow());
} else {
PgsUtils.drawDisabledBorder(g, x, y, w - 1, h - 1, 2, 2);
}

}

public Insets getBorderInsets(Component c) {
return INSETS;
}

public Insets getBorderInsets(Component c, Insets newInsets) {
newInsets.top = INSETS.top;
newInsets.left = INSETS.left;
newInsets.bottom = INSETS.bottom;
newInsets.right = INSETS.right;
return newInsets;
}
}

private static Border componentBorder;

public static Border getComponentBorder() {
if (componentBorder == null) {
componentBorder = new BorderUIResource.CompoundBorderUIResource(
new ComponentBorder(),
new BasicBorders.MarginBorder());
}
return componentBorder;
}

private static class ComponentBorder extends AbstractBorder {
private static final Insets INSETS = new Insets(1, 1, 1, 1);

public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if (c.isEnabled()) {
PgsUtils.drawButtonBorder(g, x, y, w, h);
} else {
PgsUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
}
}

public Insets getBorderInsets(Component c) {
return INSETS;
}

public Insets getBorderInsets(Component c, Insets newInsets) {
newInsets.top = INSETS.top;
newInsets.left = INSETS.left;
newInsets.bottom = INSETS.bottom;
newInsets.right = INSETS.right;
return newInsets;
}
}

private static Border toolBarBorder;

public static Border getToolBarBorder() {
if (toolBarBorder == null) {
toolBarBorder = new BorderUIResource(new ToolBarBorder());
}
return toolBarBorder;
}

public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.translate(x, y);

if (((JToolBar) c).isFloatable()) {
if (((JToolBar) c).getOrientation() == HORIZONTAL) {
PgsUtils.drawVerticalBumps(g, 2, 4, c.getHeight() - 6);
} else {
PgsUtils.drawHorizontalBumps(g, 4, 2, c.getWidth() - 6);
}
}

if (((JToolBar) c).getOrientation() == HORIZONTAL) {
g.setColor(MetalLookAndFeel.getControlShadow());
//g.drawLine(0, h - 2, w, h - 2);
g.setColor(UIManager.getColor("ToolBar.borderColor"));
g.drawLine(0, h - 1, w, h - 1);
}

g.translate(-x, -y);
}

public Insets getBorderInsets(Component c) {
return getBorderInsets(c, new Insets(0, 0, 0, 0));
}

public Insets getBorderInsets(Component c, Insets newInsets) {
newInsets.left = 2;
newInsets.top = 1;
newInsets.bottom = 2;
newInsets.right = 2;

if (((JToolBar) c).isFloatable()) {
if (((JToolBar) c).getOrientation() == HORIZONTAL) {
if (c.getComponentOrientation().isLeftToRight()) {
newInsets.left = 16;
} else {
newInsets.right = 16;
}
} else {
newInsets.top = 16;
}
}

Insets margin = ((JToolBar) c).getMargin();

if (margin != null) {
newInsets.left += margin.left;
newInsets.top += margin.top;
newInsets.right += margin.right;
newInsets.bottom += margin.bottom;
}

return newInsets;
}
}
}

0 comments on commit c8f09f1

Please sign in to comment.