class SolutionPanel<Solution_> extends JPanel implements Scrollable {

    protected static final String USAGE_EXPLANATION_PATH =
            "/org/optaplanner/examples/common/swingui/exampleUsageExplanation.png";
    // Size fits into screen resolution 1024*768
    public static final Dimension PREFERRED_SCROLLABLE_VIEWPORT_SIZE = new Dimension(800, 600);

    protected static final Color[][] INDICTMENT_COLORS = {
            { TangoColorFactory.SCARLET_3, TangoColorFactory.SCARLET_1 },
            { TangoColorFactory.ORANGE_3, TangoColorFactory.ORANGE_1 },
            { TangoColorFactory.BUTTER_3, TangoColorFactory.BUTTER_1 },
            { TangoColorFactory.CHAMELEON_3, TangoColorFactory.CHAMELEON_1 },
            { TangoColorFactory.SKY_BLUE_3, TangoColorFactory.SKY_BLUE_1 },
            { TangoColorFactory.PLUM_3, TangoColorFactory.PLUM_1 }
    };

    protected final transient Logger logger = LoggerFactory.getLogger(getClass());

    protected SolverAndPersistenceFrame<Solution_> solverAndPersistenceFrame;
    protected SolutionBusiness<Solution_, ?> solutionBusiness;

    protected boolean useIndictmentColor = false;
    protected TangoColorFactory normalColorFactory;
    protected double[] indictmentMinimumLevelNumbers;

    public SolverAndPersistenceFrame<Solution_> getSolverAndPersistenceFrame() {
        return solverAndPersistenceFrame;
    }

    public void setSolverAndPersistenceFrame(SolverAndPersistenceFrame<Solution_> solverAndPersistenceFrame) {
        this.solverAndPersistenceFrame = solverAndPersistenceFrame;
    }

    public SolutionBusiness<Solution_, ?> getSolutionBusiness() {
        return solutionBusiness;
    }

    public void setSolutionBusiness(SolutionBusiness<Solution_, ?> solutionBusiness) {
        this.solutionBusiness = solutionBusiness;
    }

    public boolean isUseIndictmentColor() {
        return useIndictmentColor;
    }

    public void setUseIndictmentColor(boolean useIndictmentColor) {
        this.useIndictmentColor = useIndictmentColor;
    }

    public String getUsageExplanationPath() {
        return USAGE_EXPLANATION_PATH;
    }

    public boolean isWrapInScrollPane() {
        return true;
    }

    public abstract void resetPanel(Solution_ solution);

    public void updatePanel(Solution_ solution) {
        resetPanel(solution);
    }

    public Solution_ getSolution() {
        return solutionBusiness.getSolution();
    }

    @Override
    public Dimension getPreferredScrollableViewportSize() {
        return PREFERRED_SCROLLABLE_VIEWPORT_SIZE;
    }

    @Override
    public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
        return 20;
    }

    @Override
    public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
        return 20;
    }

    @Override
    public boolean getScrollableTracksViewportWidth() {
        if (getParent() instanceof JViewport) {
            return (getParent().getWidth() > getPreferredSize().width);
        }
        return false;
    }

    @Override
    public boolean getScrollableTracksViewportHeight() {
        if (getParent() instanceof JViewport) {
            return (getParent().getHeight() > getPreferredSize().height);
        }
        return false;
    }

    public boolean isIndictmentHeatMapEnabled() {
        return false;
    }

    protected void preparePlanningEntityColors(List<?> planningEntityList) {<FILL_FUNCTION_BODY>}

    public Color determinePlanningEntityColor(Object planningEntity, Object normalColorObject) {
        if (useIndictmentColor) {
            Indictment<?> indictment = solutionBusiness.getIndictmentMap().get(planningEntity);
            if (indictment != null) {
                Number[] levelNumbers = indictment.getScore().toLevelNumbers();
                for (int i = 0; i < levelNumbers.length; i++) {
                    if (i > INDICTMENT_COLORS.length) {
                        return TangoColorFactory.ALUMINIUM_3;
                    }
                    double levelNumber = levelNumbers[i].doubleValue();
                    if (levelNumber < 0.0) {
                        return TangoColorFactory.buildPercentageColor(
                                INDICTMENT_COLORS[i][0], INDICTMENT_COLORS[i][1],
                                1.0 - (levelNumber / indictmentMinimumLevelNumbers[i]));
                    }
                }
            }
            return Color.WHITE;
        } else {
            return normalColorFactory.pickColor(normalColorObject);
        }
    }

    public String determinePlanningEntityTooltip(Object planningEntity) {
        Indictment<?> indictment = solutionBusiness.getIndictmentMap().get(planningEntity);
        if (indictment == null) {
            return "<html>No indictment</html>";
        }
        StringBuilder s = new StringBuilder("<html>Indictment: ").append(indictment.getScore().toShortString());
        for (ConstraintMatch<?> constraintMatch : indictment.getConstraintMatchSet()) {
            s.append("<br/>&nbsp;&nbsp;").append(constraintMatch.getConstraintName())
                    .append(" = ").append(constraintMatch.getScore().toShortString());
        }
        s.append("</html>");
        return s.toString();
    }

    public void doProblemChange(ProblemChange<Solution_> problemChange) {
        doProblemChange(problemChange, false);
    }

    public void doProblemChange(ProblemChange<Solution_> problemChange, boolean reset) {
        solutionBusiness.doProblemChange(problemChange);
        Solution_ solution = getSolution();
        Score score = solutionBusiness.getScore();
        if (reset) {
            resetPanel(solution);
        } else {
            updatePanel(solution);
        }
        validate();
        solverAndPersistenceFrame.refreshScoreField(score);
    }

}

        if (useIndictmentColor) {
            indictmentMinimumLevelNumbers = null;
            for (Object planningEntity : planningEntityList) {
                Indictment<?> indictment = solutionBusiness.getIndictmentMap().get(planningEntity);
                if (indictment != null) {
                    Number[] levelNumbers = indictment.getScore().toLevelNumbers();
                    if (indictmentMinimumLevelNumbers == null) {
                        indictmentMinimumLevelNumbers = new double[levelNumbers.length];
                        for (int i = 0; i < levelNumbers.length; i++) {
                            indictmentMinimumLevelNumbers[i] = levelNumbers[i].doubleValue();
                        }
                    } else {
                        for (int i = 0; i < levelNumbers.length; i++) {
                            double levelNumber = levelNumbers[i].doubleValue();
                            if (levelNumber < indictmentMinimumLevelNumbers[i]) {
                                indictmentMinimumLevelNumbers[i] = levelNumber;
                            }
                        }
                    }
                }
            }
        } else {
            normalColorFactory = new TangoColorFactory();
        }
    
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID