<commit_before>/*
 * Copyright (c) 2009 <NAME> and <NAME>.
 *
 * This file is part of the SeaGlass Pluggable Look and Feel.
 *
 * 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.
 * 
 * $Id$
 */
package com.seaglasslookandfeel.painter;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;

import javax.swing.JComponent;

import com.seaglasslookandfeel.painter.AbstractRegionPainter.PaintContext.CacheMode;

/**
 * Sea Glass's ArrowButtonPainter class.
 */
public final class ArrowButtonPainter extends AbstractRegionPainter {
    public static enum Which {
        BACKGROUND_ENABLED, FOREGROUND_DISABLED, FOREGROUND_ENABLED,
    }

    private Color        disabledColor = new Color(0x9ba8cf);
    private Color        enabledColor  = Color.black;

    private Which        state;
    private PaintContext ctx;

    private Path2D       path          = new Path2D.Float();

    public ArrowButtonPainter(Which state) {
        super();
        this.state = state;
        this.ctx = new PaintContext(CacheMode.FIXED_SIZES);
    }

    protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys) {
        switch (state) {
        case FOREGROUND_DISABLED:
            paintForegroundDisabled(g, width, height);
            break;
        case FOREGROUND_ENABLED:
            paintForegroundEnabled(g, width, height);
            break;
        }
    }

    protected final PaintContext getPaintContext() {
        return ctx;
    }

    private void paintForegroundDisabled(Graphics2D g, int width, int height) {
        path = decodeArrowPath(width, height);
        g.setPaint(disabledColor);
        g.fill(path);

    }

    private void paintForegroundEnabled(Graphics2D g, int width, int height) {
        path = decodeArrowPath(width, height);
        g.setPaint(enabledColor);
        g.fill(path);

    }

    private Path2D decodeArrowPath(int width, int height) {
        path.reset();
        path.moveTo(width * 0.8f, height * 0.2f);
        path.lineTo(width * 0.2f, height * 0.5f);
        path.lineTo(width * 0.8f, height * 0.8f);
        path.lineTo(width * 0.8f, height * 0.2f);
        path.closePath();
        return path;
    }
}<commit_msg>Added color for a pressed state.<commit_after>/*
 * Copyright (c) 2009 <NAME> and <NAME>.
 *
 * This file is part of the SeaGlass Pluggable Look and Feel.
 *
 * 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.
 * 
 * $Id$
 */
package com.seaglasslookandfeel.painter;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;

import javax.swing.JComponent;

import com.seaglasslookandfeel.painter.AbstractRegionPainter.PaintContext.CacheMode;

/**
 * Sea Glass's ArrowButtonPainter class.
 */
public final class ArrowButtonPainter extends AbstractRegionPainter {
    public static enum Which {
        BACKGROUND_ENABLED, FOREGROUND_DISABLED, FOREGROUND_ENABLED, FOREGROUND_PRESSED,
    }

    private Color        disabledColor = decodeColor("ArrowButton[Disabled].foreground");
    private Color        enabledColor  = decodeColor("ArrowButton[Enabled].foreground");
    private Color        pressedColor  = decodeColor("ArrowButton[Pressed].foreground");

    private Which        state;
    private PaintContext ctx;

    private Path2D       path          = new Path2D.Float();

    public ArrowButtonPainter(Which state) {
        super();
        this.state = state;
        this.ctx = new PaintContext(CacheMode.FIXED_SIZES);
    }

    protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys) {
        switch (state) {
        case FOREGROUND_DISABLED:
            paintForegroundDisabled(g, width, height);
            break;
        case FOREGROUND_ENABLED:
            paintForegroundEnabled(g, width, height);
            break;
        case FOREGROUND_PRESSED:
            paintForegroundPressed(g, width, height);
            break;
        }
    }

    protected final PaintContext getPaintContext() {
        return ctx;
    }

    private void paintForegroundDisabled(Graphics2D g, int width, int height) {
        path = decodeArrowPath(width, height);
        g.setPaint(disabledColor);
        g.fill(path);

    }

    private void paintForegroundEnabled(Graphics2D g, int width, int height) {
        path = decodeArrowPath(width, height);
        g.setPaint(enabledColor);
        g.fill(path);

    }

    private void paintForegroundPressed(Graphics2D g, int width, int height) {
        path = decodeArrowPath(width, height);
        g.setPaint(pressedColor);
        g.fill(path);

    }

    private Path2D decodeArrowPath(int width, int height) {
        path.reset();
        path.moveTo(width * 0.8f, height * 0.2f);
        path.lineTo(width * 0.2f, height * 0.5f);
        path.lineTo(width * 0.8f, height * 0.8f);
        path.lineTo(width * 0.8f, height * 0.2f);
        path.closePath();
        return path;
    }
}
{'fraction_non_alphanumeric': 0.09055844373637431, 'fraction_numerical': 0.011403655877913801, 'mean_word_length': 2.7987261146496816, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3523868', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1714, 'n_words': 506}