
it.tidalwave.forceten.lookandfeel.impl.LookAndFeelImpl Maven / Gradle / Ivy
The newest version!
/***********************************************************************************************************************
*
* forceTen - open source geography
* Copyright (C) 2007-2012 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************
*
* WWW: http://forceten.tidalwave.it
* SCM: https://bitbucket.org/tidalwave/forceten-src
*
**********************************************************************************************************************/
package it.tidalwave.forceten.lookandfeel.impl;
import java.util.logging.Logger;
import java.awt.Component;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import it.tidalwave.forceten.lookandfeel.LookAndFeel;
/*******************************************************************************
*
* A facility class with methods that contains some useful constants and can
* install UI properties for the blueMarine Look & Feel.
*
* @author Fabrizio Giudici
* @version $Id$
*
******************************************************************************/
public final class LookAndFeelImpl implements LookAndFeel
{
private static final String CLASS = LookAndFeelImpl.class.getName();
private static final Logger logger = Logger.getLogger(CLASS);
public LookAndFeelImpl()
{
}
/***************************************************************************
*
* Sets the properties for a View that lies in the main window.
*
**************************************************************************/
@Override
public void installDarkViewLAF (final JComponent parent)
{
logger.info("installDarkViewLAF(" + parent + ")");
final JComponent view = findView(parent);
logger.fine(">>>>> view: " + view);
if (view != null)
{
view.setFont(UIManager.getFont(FONT_EXPLORER));
view.setBackground(UIManager.getColor(COLOR_EXPLORER_BACKGROUND));
view.setForeground(UIManager.getColor(COLOR_EXPLORER_FOREGROUND));
view.putClientProperty("Tree.selectionForeground", UIManager.getColor(COLOR_EXPLORER_SELECTION_FOREGROUND));
view.putClientProperty("Tree.selectionBackground", UIManager.getColor(COLOR_EXPLORER_SELECTION_BACKGROUND));
installDarkLAF(view);
final Border border = UIManager.getBorder(BORDER_EXPLORER);
if (border != null)
{
view.setBorder(border);
}
}
}
private static JComponent findView (final JComponent component)
{
logger.finer("findView(" + component + ")");
if (isView(component.getClass()))
{
return component;
}
for (final Component child : component.getComponents())
{
if (child instanceof JComponent)
{
final JComponent view = findView((JComponent)child);
if (view != null)
{
return view;
}
}
}
return null;
}
private static boolean isView (final Class clazz)
{
logger.finer("isView(" + clazz + ")");
final String className = clazz.getName();
if (className.equals("org.openide.explorer.view.ListView") || className.equals("org.openide.explorer.view.TreeView"))
{
return true;
}
if (clazz.getSuperclass() == null)
{
return false;
}
return isView(clazz.getSuperclass());
}
/***************************************************************************
*
*
**************************************************************************/
@Override
public void installHeaderUI (final JPanel pnHeader)
{
// pnHeader.setUI(HeaderPanelUI.createUI(pnHeader));
}
/***************************************************************************
*
*
**************************************************************************/
@Override
public void installDarkLAF (final Component c)
{
//// if ((c instanceof JScrollBar) || c.getClass().getName().equals("javax.swing.JScrollPane$ScrollBar"))
// if (c instanceof JComponent)
// {
// try
// {
// final Class extends Component> clazz = c.getClass();
// final Method setUIMethod = clazz.getMethod("setUI", ScrollBarUI.class);
// setUIMethod.invoke(c, BlueMarineScrollBarUI.createUI((JComponent)c));
// }
// catch (NoSuchMethodException e)
// {
// e.printStackTrace(); // FIXME
// }
// catch (Exception e)
// {
// e.printStackTrace(); // FIXME
// }
//
//// if (c instanceof JToggleButton) FIXME doesn't look good
//// {
//// ((JToggleButton)c).setUI(BlueMarineToggleButtonUI.createUI((JComponent)c));
//// }
//
// for (final Component child : ((JComponent) c).getComponents())
// {
// installDarkLAF(child);
// }
// }
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy