All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.actelion.research.orbit.imageAnalysis.components.JSliderOrbit Maven / Gradle / Ivy

Go to download

Orbit, a versatile image analysis software for biological image-based quantification

There is a newer version: 3.15
Show newest version
/*
 *     Orbit, a versatile image analysis software for biological image-based quantification.
 *     Copyright (C) 2009 - 2017 Actelion Pharmaceuticals Ltd., Gewerbestrasse 16, CH-4123 Allschwil, Switzerland.
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program 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 General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see .
 *
 */

package com.actelion.research.orbit.imageAnalysis.components;

import org.pushingpixels.substance.internal.animation.StateTransitionTracker;
import org.pushingpixels.substance.internal.animation.TransitionAwareUI;
import org.pushingpixels.substance.internal.ui.SubstanceSliderUI;

import javax.swing.*;
import java.awt.*;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.awt.image.RescaleOp;

public class JSliderOrbit extends JSlider {

    public JSliderOrbit() {
        super();
        setUI(new MySubstanceSliderUI(this));
    }

    public JSliderOrbit(int orientation) {
        super(orientation);
        setUI(new MySubstanceSliderUI(this));
    }

    public JSliderOrbit(int min, int max) {
        super(min, max);
        setUI(new MySubstanceSliderUI(this));
    }

    public JSliderOrbit(int min, int max, int value) {
        super(min, max, value);
        setUI(new MySubstanceSliderUI(this));
    }

    public JSliderOrbit(int orientation, int min, int max, int value) {
        super(orientation, min, max, value);
        setUI(new MySubstanceSliderUI(this));
    }

    public JSliderOrbit(BoundedRangeModel brm) {
        super(brm);
        setUI(new MySubstanceSliderUI(this));
    }

    public static class MySubstanceSliderUI extends SubstanceSliderUI {

        public MySubstanceSliderUI (JSlider slider)
        {
            super(slider);
        }

        @Override
        protected Icon getIcon ()
        {
            // TODO Use that to get the state (-> highlight or not)
            TransitionAwareUI transitionAwareUI = (TransitionAwareUI) slider.getUI();
            StateTransitionTracker stateTransitionTracker = transitionAwareUI.getTransitionTracker();
            // stateTransitionTracker.getModelStateInfo().getCurrModelState();

            final Icon icon = super.getIcon();
            final BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
            final Graphics iconGraphics = image.createGraphics();
            icon.paintIcon(slider, iconGraphics, 0, 0);
            // Make it brighter (very simple approach)
            final RescaleOp rescaleOp = new RescaleOp(2.0f, 50, null);
            rescaleOp.filter(image, image);

            ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
            op.filter(image, image);

            return new ImageIcon(image);
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy