Update of /cvsroot/squirrel-sql/mavenize/thirdparty-non-maven/nimrodlf-1.1/src/main/java/com/nilo/plaf/nimrod
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv20856/src/main/java/com/nilo/plaf/nimrod
Added Files:
NimRODApplet.java NimRODBorders.java NimRODButtonUI.java
NimRODCheckBoxMenuItemUI.java NimRODCheckBoxUI.java
NimRODComboBoxUI.java NimRODDesktopIconUI.java
NimRODFormattedTextFieldUI.java NimRODGradientJPanel.java
NimRODIconFactory.java NimRODInternalFrameTitlePane.java
NimRODInternalFrameUI.java NimRODListUI.java
NimRODLookAndFeel.java NimRODMain.java NimRODMenuBarUI.java
NimRODMenuItemUI.java NimRODMenuUI.java
NimRODPasswordFieldUI.java NimRODPasswordView.java
NimRODPopupMenuSeparatorUI.java NimRODPopupMenuUI.java
NimRODProgressBarUI.java NimRODRadioButtonMenuItemUI.java
NimRODRadioButtonUI.java NimRODScrollBarUI.java
NimRODScrollButton.java NimRODScrollPaneUI.java
NimRODSeparatorUI.java NimRODSliderUI.java
NimRODSpinnerUI.java NimRODSplitPaneDivider.java
NimRODSplitPaneUI.java NimRODTabbedPaneUI.java
NimRODTableHeaderUI.java NimRODTextAreaUI.java
NimRODTextFieldUI.java NimRODTheme.java
NimRODToggleButtonUI.java NimRODToolBarUI.java
NimRODToolTipUI.java NimRODUtils.java
Log Message:
source for third party dependency
--- NEW FILE: NimRODButtonUI.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
/**
* Esta clase implementa los botones.
* @author Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.beans.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.swing.event.*;
public class NimRODButtonUI extends MetalButtonUI {
protected MiListener miml;
//static private NimRODButtonUI ui;
protected boolean oldOpaque;
public static ComponentUI createUI( JComponent c) {
return new NimRODButtonUI();
/*if ( ui == null ) {
ui = new NimRODButtonUI();
}
return ui;
*/
}
public void installDefaults( AbstractButton button) {
super.installDefaults( button);
button.setBorder( NimRODBorders.getButtonBorder());
selectColor = NimRODLookAndFeel.getFocusColor();
}
public void unsinstallDefaults( AbstractButton button) {
super.uninstallDefaults( button);
button.setBorder( MetalBorders.getButtonBorder());
}
public void installListeners( AbstractButton b) {
super.installListeners( b);
miml = new MiListener( b);
b.addMouseListener( miml);
b.addPropertyChangeListener( miml);
b.addFocusListener( miml);
}
protected void uninstallListeners( AbstractButton b) {
b.removeMouseListener( miml);
b.removePropertyChangeListener( miml);
b.removeFocusListener( miml);
}
protected void paintButtonPressed( Graphics g, AbstractButton b) {
if ( !oldOpaque ) {
return;
}
if ( b.isContentAreaFilled() ) {
Graphics2D g2D = (Graphics2D)g;
g2D.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2D.setColor( NimRODUtils.getColorAlfa( selectColor, 100));
RoundRectangle2D.Float boton = hazBoton( b);
g2D.fill( boton);
g2D.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
}
}
protected void paintFocus( Graphics g, AbstractButton b,
Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
if ( !b.isFocusPainted() || !oldOpaque ) {
return;
}
if ( b.getParent() instanceof JToolBar ) {
return; // No se pinta el foco cuando estamos en una barra
}
NimRODUtils.paintFocus( g, 3,3, b.getWidth()-6, b.getHeight()-6, 2, 2, NimRODLookAndFeel.getFocusColor());
}
public void update( Graphics g, JComponent c) {
oldOpaque = c.isOpaque();
if ( c.getParent() instanceof JToolBar ) {
super.update( g,c);
}
else {
c.setOpaque( false);
super.update( g,c);
c.setOpaque( oldOpaque);
}
}
public void paint( Graphics g, JComponent c) {
ButtonModel mod = ((AbstractButton)c).getModel();
if ( oldOpaque ) {
Graphics2D g2D = (Graphics2D)g;
g2D.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
RoundRectangle2D.Float boton = hazBoton( c);
// This line is a fix from Ross Judson
g2D.clip( boton);
g2D.setColor( NimRODLookAndFeel.getControl());
g2D.fill( boton);
if ( c.getParent() instanceof JToolBar ) {
if ( mod.isRollover() || mod.isPressed() || mod.isSelected()) {
c.setBorder( NimRODBorders.getGenBorder());
}
else {
c.setBorder( NimRODBorders.getEmptyGenBorder());
}
if ( mod.isPressed() || mod.isSelected() ) {
g2D.setColor( NimRODLookAndFeel.getFocusColor());
g2D.fill( boton);
}
}
else {
GradientPaint grad = null;
if ( mod.isPressed() || mod.isSelected() ) {
grad = new GradientPaint( 0,0, NimRODUtils.getSombra(),
0,c.getHeight(), NimRODUtils.getBrillo());
}
else {
grad = new GradientPaint( 0,0, NimRODUtils.getBrillo(),
0,c.getHeight(), NimRODUtils.getSombra());
}
g2D.setPaint( grad);
g2D.fill( boton);
if ( mod.isRollover() ) {
g2D.setColor( NimRODUtils.getRolloverColor());
g2D.fill( boton);
}
}
g2D.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
}
super.paint( g, c);
}
private RoundRectangle2D.Float hazBoton( JComponent c) {
RoundRectangle2D.Float boton = new RoundRectangle2D.Float();
boton.x = 0;
boton.y = 0;
boton.width = c.getWidth();
boton.height = c.getHeight();
boton.arcwidth = 8;
boton.archeight = 8;
return boton;
}
/////////////////////////////////////
public class MiListener extends MouseInputAdapter implements PropertyChangeListener, FocusListener {
private AbstractButton papi;
MiListener( AbstractButton b) {
papi = b;
}
public void refresh() {
if ( papi != null && papi.getParent() != null ) {
papi.getParent().repaint( papi.getX()-5, papi.getY()-5,
papi.getWidth()+10, papi.getHeight()+10);
}
}
public void mouseEntered( MouseEvent e) {
papi.getModel().setRollover( true);
refresh();
}
public void mouseExited( MouseEvent e) {
papi.getModel().setRollover( false);
refresh();
}
public void mousePressed(MouseEvent e) {
papi.getModel().setRollover( false);
refresh();
}
public void mouseReleased(MouseEvent e) {
papi.getModel().setRollover( false);
refresh();
}
public void propertyChange( PropertyChangeEvent evt) {
if ( evt.getPropertyName().equals( "enabled") ) {
refresh();
}
}
public void focusGained( FocusEvent e) {
refresh();
}
public void focusLost( FocusEvent e) {
refresh();
}
}
}
--- NEW FILE: NimRODUtils.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.*;
import java.util.Properties;
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
class NimRODUtils {
protected static Color rollColor;
static final int THIN = 0;
static final int FAT = 1;
static final int MATRIX_FAT = 5; // Esto define el grosor de la sombra de los titulos
static Kernel kernelFat;
static final int MATRIX_THIN = 3; // Esto define el grosor de la sombra de los menus
static Kernel kernelThin;
//static Color brillo = new Color( 255,255,255, 64);
//static Color sombra = new Color( 20,20,20, 50);
static Color getSombra() {
return getColorAlfa( getColorTercio( NimRODLookAndFeel.getControlDarkShadow(), Color.black),
64);
}
static Color getBrillo() {
return getColorAlfa( getColorTercio( NimRODLookAndFeel.getControlHighlight(), Color.white),
64);
}
static Color getSombraMenu() {
return new Color( 20,20,20, 50);
}
static Color getBrilloMenu() {
return new Color( 255,255,255, 64);
}
static NimRODTheme iniCustomColors( NimRODTheme nt, Properties props) {
String p1, p2, p3, s1, s2, s3, selection, background, w, b, opMenu, opFrame;
selection = props.getProperty( "nimrodlf.selection");
background = props.getProperty( "nimrodlf.background");
p1 = props.getProperty( "nimrodlf.p1");
p2 = props.getProperty( "nimrodlf.p2");
p3 = props.getProperty( "nimrodlf.p3");
s1 = props.getProperty( "nimrodlf.s1");
s2 = props.getProperty( "nimrodlf.s2");
s3 = props.getProperty( "nimrodlf.s3");
w = props.getProperty( "nimrodlf.w");
b = props.getProperty( "nimrodlf.b");
opMenu = props.getProperty( "nimrodlf.menuOpacity");
opFrame = props.getProperty( "nimrodlf.frameOpacity");
return iniCustomColors( nt, selection, background, p1, p2, p3, s1, s2, s3, w, b, opMenu, opFrame);
}
/**
* Esta funcion se usa para inicializar los colores del tema segun los argumentos que se le pasen.
*/
static NimRODTheme iniCustomColors( NimRODTheme nt, String selection, String background,
String p1, String p2, String p3,
String s1, String s2, String s3,
String w, String b, String opMenu, String opFrame) {
if ( selection != null ) {
nt.setPrimary( Color.decode( selection));
}
if ( background != null ) {
nt.setSecondary( Color.decode( background));
}
if ( p1 != null ) { nt.setPrimary1( Color.decode( p1)); }
if ( p2 != null ) { nt.setPrimary2( Color.decode( p2)); }
if ( p3 != null ) { nt.setPrimary3( Color.decode( p3)); }
if ( s1 != null ) { nt.setSecondary1( Color.decode( s1)); }
if ( s2 != null ) { nt.setSecondary2( Color.decode( s2)); }
if ( s3 != null ) { nt.setSecondary3( Color.decode( s3)); }
if ( w != null ) { nt.setWhite( Color.decode( w)); }
if ( b != null ) { nt.setBlack( Color.decode( b)); }
if ( opMenu != null) { nt.setMenuOpacity( Integer.parseInt( opMenu)); }
if ( opFrame != null) { nt.setFrameOpacity( Integer.parseInt( opFrame)); }
return nt;
}
static ImageIcon loadRes( String fich) {
try {
return new ImageIcon( Toolkit.getDefaultToolkit().createImage( readStream( NimRODLookAndFeel.class.getResourceAsStream( fich))));
}
catch ( Exception ex) {
ex.printStackTrace();
System.out.println( "No se puede cargar el recurso " + fich);
return null;
}
}
static byte[] readStream( InputStream input) throws IOException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
int read;
byte[] buffer = new byte[256];
while ( (read = input.read( buffer, 0, 256)) != -1 ) {
bytes.write( buffer, 0, read);
}
return bytes.toByteArray();
}
/**
* Esta funcion se usa para pintar la barra de seleccion de los menus. Esta aqui
* para no repetirla en todas partes...
*/
static void pintaBarraMenu( Graphics g, JMenuItem menuItem, Color bgColor) {
ButtonModel model = menuItem.getModel();
Color oldColor = g.getColor();
int menuWidth = menuItem.getWidth();
int menuHeight = menuItem.getHeight();
if ( menuItem.isOpaque() ) {
g.setColor( menuItem.getBackground());
g.fillRect( 0,0, menuWidth, menuHeight);
}
if ( (menuItem instanceof JMenu && !(((JMenu)menuItem).isTopLevelMenu()) && model.isSelected())
||
model.isArmed() ) {
RoundRectangle2D.Float boton = new RoundRectangle2D.Float();
boton.x = 1;
boton.y = 0;
boton.width = menuWidth - 3;
boton.height = menuHeight - 1;
boton.arcwidth = 8;
boton.archeight = 8;
GradientPaint grad = new GradientPaint( 1,1, getBrilloMenu(),
0,menuHeight, getSombraMenu());
Graphics2D g2D = (Graphics2D)g;
g2D.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor( bgColor);
g2D.fill( boton);
g.setColor( bgColor.darker());
g2D.draw( boton);
g2D.setPaint( grad);
g2D.fill( boton);
g2D.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
}
g.setColor( oldColor);
}
static void paintFocus( Graphics g, int x, int y, int width, int height, int r1, int r2, Color color) {
paintFocus( g, x, y, width, height, r1, r2, 2.0f, color);
}
static void paintFocus( Graphics g, int x, int y, int width, int height, int r1, int r2, float grosor, Color color) {
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Stroke oldStroke = g2d.getStroke();
g2d.setColor( color);
g2d.setStroke( new BasicStroke( grosor));
if ( r1 == 0 && r2 == 0 ) {
g.drawRect( x, y, width, height);
}
else {
g.drawRoundRect( x,y, width-1,height-1, r1,r2);
}
g2d.setStroke( oldStroke);
g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
}
static Color getRolloverColor() {
if ( rollColor == null ) {
rollColor = getColorAlfa( UIManager.getColor( "Button.focus"), 40);
}
return rollColor;
}
static Color getColorAlfa( Color col, int alfa) {
return new Color( col.getRed(), col.getGreen(), col.getBlue(), alfa);
}
static Color getColorMedio( Color a, Color b) {
return new Color( propInt( a.getRed(), b.getRed(), 2),
propInt( a.getGreen(), b.getGreen(), 2),
propInt( a.getBlue(), b.getBlue(), 2));
}
static ColorUIResource getColorTercio( Color a, Color b) {
return new ColorUIResource( propInt( a.getRed(), b.getRed(), 3),
propInt( a.getGreen(), b.getGreen(), 3),
propInt( a.getBlue(), b.getBlue(), 3));
}
private static int propInt( int a, int b, int prop) {
return b + ((a-b) / prop);
}
static void paintShadowTitleFat( Graphics g, String title, int x, int y, Color frente) {
paintShadowTitle( g, title, x, y, frente, Color.black, 1, FAT, SwingConstants.HORIZONTAL);
}
static void paintShadowTitleFat( Graphics g, String title, int x, int y, Color frente, Color shadow) {
paintShadowTitle( g, title, x, y, frente, shadow, 1, FAT, SwingConstants.HORIZONTAL);
}
static void paintShadowTitleFat( Graphics g, String title, int x, int y, Color frente, Color shadow, int desp) {
paintShadowTitle( g, title, x, y, frente, shadow, desp, FAT, SwingConstants.HORIZONTAL);
}
static void paintShadowTitleThin( Graphics g, String title, int x, int y, Color frente) {
paintShadowTitle( g, title, x, y, frente, Color.black, 1, THIN, SwingConstants.HORIZONTAL);
}
static void paintShadowTitleThin( Graphics g, String title, int x, int y, Color frente, Color shadow) {
paintShadowTitle( g, title, x, y, frente, shadow, 1, THIN, SwingConstants.HORIZONTAL);
}
static void paintShadowTitleThin( Graphics g, String title, int x, int y, Color frente, Color shadow, int desp) {
paintShadowTitle( g, title, x, y, frente, shadow, desp, THIN, SwingConstants.HORIZONTAL);
}
static void paintShadowTitleFatV( Graphics g, String title, int x, int y, Color frente) {
paintShadowTitle( g, title, x, y, frente, Color.black, 1, FAT, SwingConstants.VERTICAL);
}
static void paintShadowTitleFatV( Graphics g, String title, int x, int y, Color frente, Color shadow) {
paintShadowTitle( g, title, x, y, frente, shadow, 1, FAT, SwingConstants.VERTICAL);
}
static void paintShadowTitleFatV( Graphics g, String title, int x, int y, Color frente, Color shadow, int desp) {
paintShadowTitle( g, title, x, y, frente, shadow, desp, FAT, SwingConstants.VERTICAL);
}
static void paintShadowTitleThinV( Graphics g, String title, int x, int y, Color frente) {
paintShadowTitle( g, title, x, y, frente, Color.black, 1, THIN, SwingConstants.VERTICAL);
}
static void paintShadowTitleThinV( Graphics g, String title, int x, int y, Color frente, Color shadow) {
paintShadowTitle( g, title, x, y, frente, shadow, 1, THIN, SwingConstants.VERTICAL);
}
static void paintShadowTitleThinV( Graphics g, String title, int x, int y, Color frente, Color shadow, int desp) {
paintShadowTitle( g, title, x, y, frente, shadow, desp, THIN, SwingConstants.VERTICAL);
}
static void paintShadowTitle( Graphics g, String title,
int x, int y, Color frente, Color shadow,
int desp, int tipo, int orientation) {
// Si hay que rotar la fuente, se rota
Font f = g.getFont();
if ( orientation == SwingConstants.VERTICAL ) {
AffineTransform rotate = AffineTransform.getRotateInstance( Math.PI / 2);
f = f.deriveFont( rotate);
}
// Si hay que pintar sombra, se hacen un monton de cosas
if ( shadow != null ) {
int matrix = ( tipo == THIN ? MATRIX_THIN : MATRIX_FAT);
Rectangle2D rect = g.getFontMetrics().getStringBounds( title, g);
int w, h;
if ( orientation == SwingConstants.HORIZONTAL ) {
w = (int)rect.getWidth() + 6*matrix; // Hay que dejar espacio para las sombras y el borde
h = (int)rect.getHeight() + 6*matrix; // que ConvolveOp ignora por el EDGE_NO_OP
}
else {
h = (int)rect.getWidth() + 6*matrix; // Hay que dejar espacio para las sombras y el borde
w = (int)rect.getHeight() + 6*matrix; // que ConvolveOp ignora por el EDGE_NO_OP
}
// La sombra del titulo
BufferedImage iTitulo = new BufferedImage( w,h, BufferedImage.TYPE_INT_ARGB);
BufferedImage iSombra = new BufferedImage( w,h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = iTitulo.createGraphics();
g2.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setFont( f);
g2.setColor( shadow);
g2.drawString( title, 3*matrix, 3*matrix); // La pintamos en el centro
ConvolveOp cop = new ConvolveOp( ( tipo == THIN ? kernelThin : kernelFat), ConvolveOp.EDGE_NO_OP, null);
cop.filter( iTitulo, iSombra); // A ditorsionar
// Por fin, pintamos el jodio titulo
g.drawImage( iSombra,
x - 3*matrix + desp, // Lo llevamos a la posicion original y le sumamos 1
y - 3*matrix + desp, // para que la sombra quede pelin desplazada
null);
}
// Si hay que pintar el frente, se pinta
if ( frente != null ) {
g.setFont( f);
g.setColor( frente);
g.drawString( title, x, y);
}
}
static Icon reescala( Icon ic, int maxW, int maxH) {
if ( ic == null ) {
return null;
}
if ( ic.getIconHeight() == maxH && ic.getIconWidth() == maxW ) {
return ic;
}
BufferedImage bi = new BufferedImage( ic.getIconHeight(), ic.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.createGraphics();
ic.paintIcon( null, g, 0, 0);
g.dispose();
Image bf = bi.getScaledInstance( maxW, maxH, Image.SCALE_SMOOTH);
return new ImageIcon( bf);
}
static int getOpacity() {
return getMenuOpacity();
}
static int getMenuOpacity() {
try {
NimRODTheme th = (NimRODTheme)NimRODLookAndFeel.theme;
return th.getMenuOpacity();
}
catch ( Throwable ex) {
return NimRODTheme.DEFAULT_MENU_OPACITY;
}
}
static float getMenuOpacityFloat() {
return getMenuOpacity() / 255f;
}
static int getFrameOpacity() {
try {
NimRODTheme th = (NimRODTheme)NimRODLookAndFeel.theme;
return th.getFrameOpacity();
}
catch ( Throwable ex) {
return NimRODTheme.DEFAULT_FRAME_OPACITY;
}
}
static float getFrameOpacityFloat() {
return getFrameOpacity() / 255f;
}
}
--- NEW FILE: NimRODSplitPaneUI.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
/**
* Esta clase implementa los SplitPanes.
* El trabajo realmente lo hace la clase NimRODSplitPaneDivider.
* @see NimRODSplitPaneDividier
* @author Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.metal.MetalSplitPaneUI;
public class NimRODSplitPaneUI extends MetalSplitPaneUI {
public static ComponentUI createUI( JComponent c) {
return new NimRODSplitPaneUI();
}
public BasicSplitPaneDivider createDefaultDivider() {
return new NimRODSplitPaneDivider( this);
}
}
--- NEW FILE: NimRODProgressBarUI.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
/**
* Esta clase implementa las barras de progreso.
* @author Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
public class NimRODProgressBarUI extends BasicProgressBarUI {
public static ComponentUI createUI( JComponent c) {
return new NimRODProgressBarUI();
}
public void paintDeterminate( Graphics g, JComponent c) {
Graphics2D g2D = (Graphics2D)g;
Insets b = progressBar.getInsets();
int largo = progressBar.getWidth() - (b.left + b.right);
int alto = progressBar.getHeight() - (b.top + b.bottom);
int len = getAmountFull(b, largo, alto);
int xi = b.left;
int yi = b.top;
int xf = xi + largo;
int yf = yi + alto;
int xm = xi + len - 1;
int ym = yf - len ;
if ( progressBar.getOrientation() == JProgressBar.HORIZONTAL ) {
g2D.setColor( progressBar.getForeground());
g2D.fillRect( xi,yi, xm,yf);
GradientPaint grad = new GradientPaint( xi,yi, NimRODUtils.getBrillo(),
xi,yf, NimRODUtils.getSombra());
g2D.setPaint( grad);
g2D.fillRect( xi,yi, xm,yf);
grad = new GradientPaint( xm+1,yi, NimRODUtils.getSombra(),
xm+1,yf, NimRODUtils.getBrillo());
g2D.setPaint( grad);
g2D.fillRect( xm+1,yi, xf,yf);
}
else {
g2D.setColor( progressBar.getForeground());
g2D.fillRect( xi,ym, xf,yf);
GradientPaint grad = new GradientPaint( xi,yi, NimRODUtils.getSombra(),
xf,yi, NimRODUtils.getBrillo());
g2D.setPaint( grad);
g2D.fillRect( xi,yi, xf,ym);
grad = new GradientPaint( xi,ym, NimRODUtils.getBrillo(),
xf,ym, NimRODUtils.getSombra());
g2D.setPaint( grad);
g2D.fillRect( xi,ym, xf,yf);
}
paintString(g, 0,0,0,0,0, b);
}
public void paintIndeterminate( Graphics g, JComponent c) {
Graphics2D g2D = (Graphics2D)g;
Rectangle rec = new Rectangle();
rec = getBox( rec);
Insets b = progressBar.getInsets();
int xi = b.left;
int yi = b.top;
int xf = c.getWidth() - b.right;
int yf = c.getHeight() - b.bottom;
g2D.setColor( progressBar.getForeground());
g2D.fillRect( rec.x, rec.y, rec.width, rec.height);
if ( progressBar.getOrientation() == JProgressBar.HORIZONTAL ) {
GradientPaint grad = new GradientPaint( rec.x,rec.y, NimRODUtils.getBrillo(),
rec.x,rec.height, NimRODUtils.getSombra());
g2D.setPaint( grad);
g2D.fill( rec);
grad = new GradientPaint( xi,yi, NimRODUtils.getSombra(),
xi,yf, NimRODUtils.getBrillo());
g2D.setPaint( grad);
g2D.fillRect( xi,yi, rec.x,yf);
g2D.fillRect( rec.x + rec.width,yi, xf,yf);
}
else {
GradientPaint grad = new GradientPaint( rec.x,rec.y, NimRODUtils.getBrillo(),
rec.width,rec.y, NimRODUtils.getSombra());
g2D.setPaint( grad);
g2D.fill( rec);
grad = new GradientPaint( xi,yi, NimRODUtils.getSombra(),
xf,yi, NimRODUtils.getBrillo());
g2D.setPaint( grad);
g2D.fillRect( xi,yi, xf,rec.y);
g2D.fillRect( xi,rec.y+rec.height, xf,yf);
}
paintString( g2D, 0,0,0,0, 0, b);
}
protected void paintString( Graphics g, int x, int y, int width, int height, int amountFull, Insets b) {
if ( !progressBar.isStringPainted()) {
return;
}
String text = progressBar.getString();
Point point = getStringPlacement( g, text, b.left, b.top,
progressBar.getWidth() - b.left - b.right,
progressBar.getHeight() - b.top - b.bottom);
g.setFont( progressBar.getFont().deriveFont( Font.BOLD));
if ( progressBar.getOrientation() == JProgressBar.HORIZONTAL ) {
if ( !progressBar.getComponentOrientation().isLeftToRight() ) {
point.x += progressBar.getFontMetrics( g.getFont()).stringWidth( text);
}
}
NimRODUtils.paintShadowTitle( g, text, point.x, point.y, Color.white, Color.black, 1,
NimRODUtils.FAT, progressBar.getOrientation());
}
}
--- NEW FILE: NimRODTableHeaderUI.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
/**
* Esta clase implementa las cabeceras de las tablas.
* @author Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
public class NimRODTableHeaderUI extends BasicTableHeaderUI {
public NimRODTableHeaderUI() {
}
public static ComponentUI createUI( JComponent c) {
return new NimRODTableHeaderUI();
}
public void paint( Graphics g, JComponent c) {
g.translate( 3, 0);
super.paint( g, c);
g.translate( -3, 0);
if ( !c.isOpaque() ) {
return;
}
Graphics2D g2D = (Graphics2D)g;
GradientPaint grad = new GradientPaint( 0,0, NimRODUtils.getBrillo(),
0,c.getHeight(), NimRODUtils.getSombra());
g2D.setPaint( grad);
g2D.fillRect( 0,0, c.getWidth(),c.getHeight());
}
}
--- NEW FILE: NimRODPasswordView.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
/**
* Esta clase implementa los campos de password.
* Esta clase cambia los asteriscos habituales por unos cuadrados con bordes redondeados
* @see NimRODPasswordFieldUI
* @author Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class NimRODPasswordView extends PasswordView {
protected static int ancho = 9;
protected static int hueco = 3;
public NimRODPasswordView( Element elem) {
super( elem);
}
protected int drawEchoCharacter( Graphics g, int x, int y, char c) {
int w = getFontMetrics().charWidth( c);
w = ( w < ancho ? ancho : w);
int h = (getContainer().getHeight() - ancho) / 2;
Graphics2D g2D = (Graphics2D)g;
g2D.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2D.fillOval( x, h+1, w, w);
g2D.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
return x + w + hueco;
}
public Shape modelToView( int pos, Shape a, Position.Bias b) throws BadLocationException {
Container c = getContainer();
if ( c instanceof JPasswordField ) {
JPasswordField f = (JPasswordField)c;
if ( !f.echoCharIsSet() ) {
return super.modelToView( pos, a, b);
}
char echoChar = f.getEchoChar();
int w = f.getFontMetrics( f.getFont()).charWidth( echoChar);
w = ( w < ancho ? ancho : w) + hueco;
Rectangle alloc = adjustAllocation( a).getBounds();
int dx = (pos - getStartOffset()) * w;
alloc.x += dx - 2;
if ( alloc.x <= 5 ) {
alloc.x = 6;
}
alloc.width = 1;
return alloc;
}
return null;
}
public int viewToModel( float fx, float fy, Shape a, Position.Bias[] bias) {
bias[0] = Position.Bias.Forward;
int n = 0;
Container c = getContainer();
if ( c instanceof JPasswordField ) {
JPasswordField f = (JPasswordField)c;
if ( !f.echoCharIsSet() ) {
return super.viewToModel( fx, fy, a, bias);
}
char echoChar = f.getEchoChar();
int w = f.getFontMetrics( f.getFont()).charWidth( echoChar);
w = ( w < ancho ? ancho : w) + hueco;
a = adjustAllocation( a);
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : a.getBounds();
n = ((int)fx - alloc.x) / w;
if (n < 0) {
n = 0;
}
else if ( n > (getStartOffset() + getDocument().getLength()) ) {
n = getDocument().getLength() - getStartOffset();
}
}
return getStartOffset() + n;
}
}
--- NEW FILE: NimRODScrollButton.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
/**
* Esta clase implementa los botones de las barras de scroll.
* @author Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.metal.*;
public class NimRODScrollButton extends MetalScrollButton {
private static final long serialVersionUID = 1L;
public NimRODScrollButton( int direction, int width, boolean freeStanding) {
super( direction, width+1, freeStanding);
}
public void paint( Graphics g) {
Rectangle rec = new Rectangle( 0,0, getWidth(),getHeight());
Graphics2D g2D = (Graphics2D)g;
GradientPaint grad = null;
if (getDirection() == SwingConstants.EAST || getDirection() == SwingConstants.WEST) {
if ( getModel().isPressed() || getModel().isSelected() ) {
grad = new GradientPaint( 0,0, NimRODUtils.getSombra(),
0,rec.height, NimRODUtils.getBrillo());
}
else {
grad = new GradientPaint( 0,0, NimRODUtils.getBrillo(),
0,rec.height, NimRODUtils.getSombra());
}
}
else {
if ( getModel().isPressed() || getModel().isSelected() ) {
grad = new GradientPaint( 0,0, NimRODUtils.getSombra(),
rec.width,0, NimRODUtils.getBrillo());
}
else {
grad = new GradientPaint( 0,0, NimRODUtils.getBrillo(),
rec.width,0, NimRODUtils.getSombra());
}
}
g2D.setColor( NimRODLookAndFeel.getControl());
g2D.fillRect( rec.x, rec.y, rec.width, rec.height);
g2D.setPaint( grad);
g2D.fillRect( rec.x, rec.y, rec.width, rec.height);
if ( getModel().isRollover() ) {
g2D.setColor( NimRODUtils.getRolloverColor());
g2D.fillRect( rec.x, rec.y, rec.width, rec.height);
}
g2D.setColor( NimRODLookAndFeel.getControlDarkShadow());
g2D.drawRect( rec.x, rec.y, rec.width-1, rec.height-1);
Icon icon = null;
switch ( getDirection() ) {
case SwingConstants.EAST : icon = UIManager.getIcon( "ScrollBar.eastButtonIcon"); break;
case SwingConstants.WEST : icon = UIManager.getIcon( "ScrollBar.westButtonIcon"); break;
case SwingConstants.NORTH : icon = UIManager.getIcon( "ScrollBar.northButtonIcon"); break;
case SwingConstants.SOUTH : icon = UIManager.getIcon( "ScrollBar.southButtonIcon"); break;
}
icon.paintIcon( this, g2D, rec.x, rec.y);
}
}
--- NEW FILE: NimRODDesktopIconUI.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
public class NimRODDesktopIconUI extends BasicDesktopIconUI {
boolean hasFocus;
private int width = UIManager.getInt( "NimRODDesktopIcon.width");
private int height = UIManager.getInt( "NimRODDesktopIcon.height");
private int bigWidth = UIManager.getInt( "NimRODDesktopIconBig.width");
private int bigHeight = UIManager.getInt( "NimRODDesktopIconBig.height");
private HackML hackML;
private Icon resizeIcon, antIcon;
public static ComponentUI createUI( JComponent c) {
return new NimRODDesktopIconUI();
}
public NimRODDesktopIconUI() {
super();
hackML = new HackML();
}
protected void installDefaults() {
super.installDefaults();
LookAndFeel.uninstallBorder( desktopIcon);
}
protected void installComponents() {}
protected void uninstallComponents() {}
protected void installListeners() {
super.installListeners();
if ( frame != null ) {
desktopIcon.addMouseListener( hackML);
desktopIcon.addMouseMotionListener( hackML);
}
}
protected void uninstallListeners() {
super.uninstallListeners();
desktopIcon.removeMouseListener( hackML);
desktopIcon.removeMouseMotionListener( hackML);
}
public void update( Graphics g, JComponent c) {
paint( g, c);
}
public void paint( Graphics g, JComponent c) {
if ( frame.getFrameIcon() != antIcon ) {
antIcon = frame.getFrameIcon();
resizeIcon = NimRODUtils.reescala( antIcon, bigWidth, bigHeight);
}
String title = frame.getTitle();
int x = 0;
if ( resizeIcon != null ) {
x = ( width - resizeIcon.getIconWidth() ) / 2;
resizeIcon.paintIcon( c, g, x, 2);
}
g.setFont( UIManager.getFont( "DesktopIcon.font"));
FontMetrics fm = g.getFontMetrics();
if ( hasFocus ) {
int y = 0;
String auxTit = getTitle( title, fm, width-10); // Los anglos se mearan de risa al ver el nombre de esta variable...
while ( auxTit.length() > 0 ) {
if ( auxTit.endsWith( "...") ) {
auxTit = auxTit.substring( 0, auxTit.length()-3);
}
Rectangle2D rect = fm.getStringBounds( auxTit, g);
x = (int)( width - rect.getWidth() ) / 2;
y += rect.getHeight();
NimRODUtils.paintShadowTitleFat( g, auxTit, x, y, Color.white);
title = title.substring( auxTit.length());
auxTit = getTitle( title, fm, width-10);
}
}
else {
title = getTitle( title, fm, width-10);
Rectangle2D rect = fm.getStringBounds( title, g);
x = (int)( width - rect.getWidth() ) / 2;
NimRODUtils.paintShadowTitleFat( g, title, x, height-NimRODUtils.MATRIX_FAT, Color.white);
}
}
protected String getTitle( String title, FontMetrics fm, int len) {
if ( title == null || title.equals( "") ) {
return "";
}
int lTit = fm.stringWidth( title);
if ( lTit <= len ) {
return title;
}
int lPuntos = fm.stringWidth( "...");
if ( len - lPuntos <= 0 ) {
return "";
}
int i = 1;
do {
String aux = title.substring( 0, i++) + "...";
lPuntos = fm.stringWidth( aux);
} while ( lPuntos < len);
return title.substring( 0, i-1) + "...";
}
public Dimension getPreferredSize( JComponent c) {
return getMinimumSize( c);
}
public Dimension getMaximumSize( JComponent c) {
return getMinimumSize( c);
}
public Dimension getMinimumSize( JComponent c) {
return new Dimension( width, height);
}
//******************************+
private class HackML extends MouseInputAdapter {
public void mouseReleased( MouseEvent ev) {
dodo( ev);
}
public void mousePressed( MouseEvent ev) {
dodo( ev);
}
public void mouseExited( MouseEvent ev) {
hasFocus = false;
dodo( ev);
}
public void mouseEntered( MouseEvent ev) {
hasFocus = true;
dodo( ev);
}
public void mouseDragged( MouseEvent ev) {
dodo( ev);
}
void dodo( MouseEvent ev) {
if ( desktopIcon != null ) {
desktopIcon.getDesktopPane().updateUI();
}
}
}
}
--- NEW FILE: NimRODTextFieldUI.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
/**
* Esta clase implementa los TextField.
* Esta clase se usa desde un monton de sitios (Combos, PasswordField...), asi que extenderla
* tiene resultados mas alla de los campos de texto.
* @author Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
public class NimRODTextFieldUI extends BasicTextFieldUI {
private boolean rollover = false;
private boolean focus = false;
private MiTextML miTextML;
protected boolean oldOpaque, canijo;
NimRODTextFieldUI( JComponent c) {
super();
}
public static ComponentUI createUI( JComponent c) {
return new NimRODTextFieldUI( c);
}
protected void installDefaults() {
super.installDefaults();
oldOpaque = getComponent().isOpaque();
getComponent().setOpaque( false);
}
protected void uninstallDefaults() {
super.uninstallDefaults();
getComponent().setOpaque( oldOpaque);
}
protected void installListeners() {
super.installListeners();
miTextML = new MiTextML();
getComponent().addMouseListener( miTextML);
getComponent().addFocusListener( miTextML);
}
protected void uninstallListeners() {
super.uninstallListeners();
getComponent().removeMouseListener( miTextML);
getComponent().removeFocusListener( miTextML);
}
public boolean isFocus() {
return focus;
}
public boolean isRollover() {
return rollover;
}
protected void paintSafely( Graphics g) {
paintFocus( g);
paintTodo( g);
super.paintSafely( g);
}
protected void paintTodo( Graphics g) {
JTextComponent c = getComponent();
Border bb = c.getBorder();
if ( bb != null && bb instanceof NimRODBorders.NimRODGenBorder ) {
Insets ins = NimRODBorders.getTextFieldBorder().getBorderInsets( c);
// Si cabe todo, le ponemos un borde guay. Si no, pues le dejamos un borde cutrecillo
if ( c.getSize().height+2 < (c.getFont().getSize() + ins.top + ins.bottom) ) {
c.setBorder( NimRODBorders.getThinGenBorder());
canijo = true;
}
else {
c.setBorder( NimRODBorders.getTextFieldBorder());
canijo = false;
}
if ( !c.isEditable() || !c.isEnabled() ) {
g.setColor( UIManager.getColor( "TextField.inactiveBackground"));
}
else {
g.setColor( c.getBackground());
}
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.fillRoundRect( 2,2, c.getWidth()-4, c.getHeight()-4, 7,7);
g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
}
else {
super.paintBackground( g);
}
}
protected void paintBackground( Graphics g) {
}
protected void paintFocus( Graphics g) {
JTextComponent c = getComponent();
if ( c.isEnabled() && c.isEditable() && !canijo ) {
if ( focus ) {
NimRODUtils.paintFocus( g, 1,1, c.getWidth()-2, c.getHeight()-2, 4,4, 3, NimRODLookAndFeel.getFocusColor());
}
else if ( rollover ) {
NimRODUtils.paintFocus( g, 1,1, c.getWidth()-2, c.getHeight()-2, 4,4, 3, NimRODUtils.getColorAlfa( NimRODLookAndFeel.getFocusColor(), 150));
}
}
}
//////////////////////////
class MiTextML extends MouseAdapter implements FocusListener {
protected void refresh() {
if ( getComponent().getParent() != null ) {
Component papi = getComponent();
papi.getParent().repaint( papi.getX()-5, papi.getY()-5,
papi.getWidth()+10, papi.getHeight()+10);
}
}
public void mouseExited( MouseEvent e) {
rollover = false;
refresh();
}
public void mouseEntered( MouseEvent e) {
rollover = true;
refresh();
}
public void focusGained( FocusEvent e) {
focus = true;
refresh();
}
public void focusLost( FocusEvent e) {
focus = false;
refresh();
}
}
}
--- NEW FILE: NimRODToolTipUI.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
public class NimRODToolTipUI extends MetalToolTipUI {
protected JToolTip tooltip;
public NimRODToolTipUI( JComponent c) {
super();
tooltip = (JToolTip)c;
tooltip.setOpaque( false);
}
public static ComponentUI createUI( JComponent c) {
return new NimRODToolTipUI( c);
}
public void paint( Graphics g, JComponent c) {
int w = tooltip.getWidth();
int h = tooltip.getHeight();
Border bb = tooltip.getBorder();
if ( bb != null ) {
w -= bb.getBorderInsets( tooltip).right;
h -= bb.getBorderInsets( tooltip).bottom;
}
g.setColor( tooltip.getBackground());
g.fillRect( 0,0, w,h);
super.paint( g, c);
}
}
--- NEW FILE: NimRODIconFactory.java ---
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Español)
*
*
* Original author: Nilo J. Gonzalez
*/
/**
* Esta clase dibuja varios de los iconos que se usan a lo largo de todo el LookAndFeel.
* Esta es la clase que hace el trabajo duro de pintar checkboxes, radios, sliders... Consta de
* varias inner clases privadas y de funciones que las dan acceso. Las inner clases mas o menos
* son todas iguales: pintan un icono base leido de un archivo PNG, segun cual sea el estado del
* objeto (seleccionado, inactivo...) le dan una capa de color y si es necesario vuelven a pintar
* otro icono.
* Podria hacerse mas sencillo pintando un unico icono segun el estado del componente, teniendo
* un PNG por cada estado, pero entonces no se podria usar colores en ellos porque si cambiara el
* color de seleccion o foco, por ejemplo a verde, todos los objetos de la aplicacion se pintarian
* seleccionados en verde menos los iconos, que se pintarian con el color con que hubieramos pintado
* el PNG, dando un aspecto inconsistente. Por eso se pinta un icono trasparente y una capa de color
* cuando hace falta, para decidir en tiempo real cual es el color apropiado.
* @author Nilo J. Gonzalez
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.io.Serializable;
public class NimRODIconFactory implements Serializable {
private static final long serialVersionUID = 7191199335114123414L;
private static Icon checkBoxIcon;
private static Icon radioButtonIcon;
private static Icon checkBoxMenuItemIcon;
private static Icon radioButtonMenuItemIcon;
private static Icon sliderHorizIcon;
private static Icon sliderVertIcon;
private static Icon treeCollapsedIcon;
private static Icon treeExpandedIcon;
private static Icon bandaMenuItemIcon;
private static Icon comboFlechaIcon;
private static Icon scrollNorthIcon;
private static Icon scrollSouthIcon;
private static Icon scrollEastIcon;
private static Icon scrollWestIcon;
private static Icon frameCloseIcon;
private static Icon frameMaxIcon;
private static Icon frameMinIcon;
private static Icon frameAltMaximizeIcon;
private static Icon spinnerNextIcon;
private static Icon spinnerPreviousIcon;
public static Icon getSpinnerNextIcon() {
if ( spinnerNextIcon == null ) {
spinnerNextIcon = new SpinnerNextIcon();
}
return spinnerNextIcon;
}
public static Icon getSpinnerPreviousIcon() {
if ( spinnerPreviousIcon == null ) {
spinnerPreviousIcon = new SpinnerPreviousIcon();
}
return spinnerPreviousIcon;
}
public static Icon getFrameCloseIcon() {
if ( frameCloseIcon == null ) {
frameCloseIcon = new FrameGenericIcon( "InternalFrame.NimCloseIcon",
"InternalFrame.NimCloseIconRoll",
"InternalFrame.NimCloseIconPush");
}
return frameCloseIcon;
}
public static Icon getFrameMaxIcon() {
if ( frameMaxIcon == null ) {
frameMaxIcon = new FrameGenericIcon( "InternalFrame.NimMaxIcon",
"InternalFrame.NimMaxIconRoll",
"InternalFrame.NimMaxIconPush");
}
return frameMaxIcon;
}
public static Icon getFrameMinIcon() {
if ( frameMinIcon == null ) {
frameMinIcon = new FrameGenericIcon( "InternalFrame.NimMinIcon",
"InternalFrame.NimMinIconRoll",
"InternalFrame.NimMinIconPush");
}
return frameMinIcon;
}
public static Icon getFrameAltMaximizeIcon() {
if ( frameAltMaximizeIcon == null ) {
frameAltMaximizeIcon = new FrameGenericIcon( "InternalFrame.NimResizeIcon",
"InternalFrame.NimResizeIconRoll",
"InternalFrame.NimResizeIconPush");
}
return frameAltMaximizeIcon;
}
public static Icon getComboFlechaIcon() {
if ( comboFlechaIcon == null ) {
comboFlechaIcon = new ComboFlechaIcon();
}
return comboFlechaIcon;
}
public static Icon getBandaMenuItemIcon() {
if ( bandaMenuItemIcon == null ) {
bandaMenuItemIcon = new BandaMenuItemIcon();
}
return bandaMenuItemIcon;
}
public static Icon getCheckBoxIcon() {
if ( checkBoxIcon == null ) {
checkBoxIcon = new CheckBoxIcon();
}
return checkBoxIcon;
}
public static Icon getRadioButtonIcon() {
if ( radioButtonIcon == null ) {
radioButtonIcon = new RadioButtonIcon();
}
return radioButtonIcon;
}
public static Icon getCheckBoxMenuItemIcon() {
if ( checkBoxMenuItemIcon == null ) {
checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
}
return checkBoxMenuItemIcon;
}
public static Icon getRadioButtonMenuItemIcon() {
if ( radioButtonMenuItemIcon == null ) {
radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
}
return radioButtonMenuItemIcon;
}
public static Icon getSliderVerticalIcon() {
if ( sliderVertIcon == null ) {
sliderVertIcon = new SliderVerticalIcon();
}
return sliderVertIcon;
}
public static Icon getSliderHorizontalIcon() {
if ( sliderHorizIcon == null ) {
sliderHorizIcon = new SliderHorizontalIcon();
}
return sliderHorizIcon;
}
public static Icon getTreeCollapsedIcon() {
if ( treeCollapsedIcon == null ) {
treeCollapsedIcon = new TreeCollapsedIcon();
}
return treeCollapsedIcon;
}
public static Icon getTreeExpandedIcon() {
if ( treeExpandedIcon == null ) {
treeExpandedIcon = new TreeExpandedIcon();
}
return treeExpandedIcon;
}
public static Icon getScrollBarNorthButtonIcon() {
if ( scrollNorthIcon == null ) {
scrollNorthIcon = new ScrollBarNorthButtonIcon();
}
return scrollNorthIcon;
}
public static Icon getScrollBarSouthButtonIcon() {
if ( scrollSouthIcon == null ) {
scrollSouthIcon = new ScrollBarSouthButtonIcon();
}
return scrollSouthIcon;
}
public static Icon getScrollBarEastButtonIcon() {
if ( scrollEastIcon == null ) {
scrollEastIcon = new ScrollBarEastButtonIcon();
}
return scrollEastIcon;
}
public static Icon getScrollBarWestButtonIcon() {
if ( scrollWestIcon == null ) {
scrollWestIcon = new ScrollBarWestButtonIcon();
}
return scrollWestIcon;
}
/******************************************************************************************/
private static class ComboFlechaIcon implements Icon, UIResource, Serializable {
private static final long serialVersionUID = -3071886619903027901L;
private int w, h;
public ComboFlechaIcon() {
w = 15;
h = 15;
}
public void paintIcon( Component c, Graphics g, int x, int y ) {
Icon icon = UIManager.getIcon( "ComboBox.flechaIcon");
w = icon.getIconWidth();
h = icon.getIconHeight();
icon.paintIcon( c, g, x, y);
g.setColor( NimRODLookAndFeel.getFocusColor());
g.drawLine( x+2, y+5, x+7, y+10);
g.drawLine( x+7, y+10, x+12, y+5);
g.drawLine( x+2, y+4, x+7, y+9);
g.drawLine( x+7, y+9, x+12, y+4);
}
public int getIconWidth() {
return w;
}
public int getIconHeight() {
return h;
}
}
/******************************************************************************************/
private static class ScrollBarNorthButtonIcon implements Icon, UIResource, Serializable {
private static final long serialVersionUID = -3074532619903027901L;
private int w, h;
public ScrollBarNorthButtonIcon() {
w = 15;
h = 15;
}
public void paintIcon( Component c, Graphics g, int x, int y ) {
Icon icon = UIManager.getIcon( "ScrollBar.northButtonIconImage");
w = icon.getIconWidth();
h = icon.getIconHeight();
icon.paintIcon( c, g, x, y);
g.setColor( NimRODLookAndFeel.getFocusColor());
g.drawLine( x+2, y+8, x+7, y+3);
g.drawLine( x+7, y+3, x+12, y+8);
g.drawLine( x+2, y+9, x+7, y+4);
g.drawLine( x+7, y+4, x+12, y+9);
}
public int getIconWidth() {
return w;
}
public int getIconHeight() {
return h;
}
}
/******************************************************************************************/
private static class ScrollBarSouthButtonIcon implements Icon,...
[truncated message content] |