<commit_before>/*
 * $Id$
 *
 * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle,
 * Santa Clara, California 95054, U.S.A. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */
package org.jdesktop.swingx.renderer;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.text.DateFormat;
import java.util.logging.Logger;

import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.ToolTipManager;
import javax.swing.tree.DefaultMutableTreeNode;

import junit.framework.TestCase;

import org.jdesktop.swingx.JXHyperlink;
import org.jdesktop.swingx.JXPanel;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.JXTreeTable;
import org.jdesktop.swingx.action.LinkAction;
import org.jdesktop.swingx.painter.ShapePainter;
import org.jdesktop.swingx.table.TableColumnExt;
import org.jdesktop.swingx.test.ComponentTreeTableModel;
import org.jdesktop.swingx.test.XTestUtils;
import org.jdesktop.test.PropertyChangeReport;
import org.jdesktop.test.TestUtils;

/**
 * Tests swingx rendering infrastructure: ComponentProvider, CellContext, 
 * ..
 * 
 * 
 * @author <NAME>
 */
public class RenderingTest extends TestCase {
    private static final Logger LOG = Logger.getLogger(RenderingTest.class
            .getName());

    /**
     * Issue #840-swingx: hyperlink foreground unreadable for dark selection colors.
     * 
     * Test that selected foreground is same as table. 
     * 
     */
    public void testHyperlinkProviderForeground() {
        JXTable table = new JXTable(20, 2);
        HyperlinkProvider provider = new HyperlinkProvider();
        JXHyperlink hyperlink = provider.getRendererComponent(null);
        Color unclicked = hyperlink.getUnclickedColor();
        table.setDefaultRenderer(Object.class, new DefaultTableRenderer(provider));
        table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
        assertEquals("hyperlink foreground set to unclicked", unclicked, hyperlink.getForeground());
        table.setRowSelectionInterval(0, 0);
        // JW: had been failing before because I forgot to re-prepare :-)
        table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
        assertEquals("hyperlink foreground set to table's selection foreground", 
                table.getSelectionForeground(), hyperlink.getForeground());<commit_msg>dummy commit ..<commit_after>/*
 * $Id$
 *
 * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle,
 * Santa Clara, California 95054, U.S.A. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */
package org.jdesktop.swingx.renderer;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.text.DateFormat;
import java.util.logging.Logger;

import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.ToolTipManager;
import javax.swing.tree.DefaultMutableTreeNode;

import junit.framework.TestCase;

import org.jdesktop.swingx.JXHyperlink;
import org.jdesktop.swingx.JXPanel;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.JXTreeTable;
import org.jdesktop.swingx.action.LinkAction;
import org.jdesktop.swingx.painter.ShapePainter;
import org.jdesktop.swingx.table.TableColumnExt;
import org.jdesktop.swingx.test.ComponentTreeTableModel;
import org.jdesktop.swingx.test.XTestUtils;
import org.jdesktop.test.PropertyChangeReport;
import org.jdesktop.test.TestUtils;

/**
 * Tests swingx rendering infrastructure: ComponentProvider, CellContext, 
 * ..
 * 
 * 
 * @author <NAME>
 */
public class RenderingTest extends TestCase {
    @SuppressWarnings("unused")
    private static final Logger LOG = Logger.getLogger(RenderingTest.class
            .getName());

    /**
     * Issue #840-swingx: hyperlink foreground unreadable for dark selection colors.
     * 
     * Test that selected foreground is same as table. 
     * 
     */
    public void testHyperlinkProviderForeground() {
        JXTable table = new JXTable(20, 2);
        HyperlinkProvider provider = new HyperlinkProvider();
        JXHyperlink hyperlink = provider.getRendererComponent(null);
        Color unclicked = hyperlink.getUnclickedColor();
        table.setDefaultRenderer(Object.class, new DefaultTableRenderer(provider));
        table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
        assertEquals("hyperlink foreground set to unclicked", unclicked, hyperlink.getForeground());
        table.setRowSelectionInterval(0, 0);
        // JW: had been failing before because I forgot to re-prepare :-)
        table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
        assertEquals("hyperlink foreground set to table's selection foreground", 
                table.getSelectionForeground(), hyperlink.getForeground());
{'fraction_non_alphanumeric': 0.09041980624327234, 'fraction_numerical': 0.012917115177610334, 'mean_word_length': 4.0418604651162795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6611167', 'n_tokens_mistral': 1913, 'n_tokens_neox': 1775, 'n_words': 568}