source: git/Singular/LIB/surfex/AppearanceScheme.java @ 3de2ca

spielwiese
Last change on this file since 3de2ca was 3de2ca, checked in by Hans Schönemann <hannes@…>, 16 years ago
*hannes: surfex_0_90_00 git-svn-id: file:///usr/local/Singular/svn/trunk@11070 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.3 KB
Line 
1////////////////////////////////////////////////////////////////////////
2//
3// This file AppearanceScheme.java is part of SURFEX.
4//
5////////////////////////////////////////////////////////////////////////
6
7////////////////////////////////////////////////////////////////////////
8// SURFEX version 0.90.00
9// =================
10//
11// Saarland University at Saarbruecken, Germany
12// Department of Mathematics and Computer Science
13//
14// SURFEX on the web: www.surfex.AlgebraicSurface.net
15//
16// Authors: Oliver Labs (2001-2008), Stephan Holzer (2004-2005)
17//
18// Copyright (C) 2001-2008
19//
20//
21// *NOTICE*
22// ========
23// 
24// This program is free software; you can redistribute it and/or modify it
25// under the terms of the GNU General Public License as published by the
26// Free Software Foundation ( version 3 or later of the License ).
27//
28// See LICENCE.TXT for details.
29//
30/////////////////////////////////////////////////////////////////////////
31
32
33import java.awt.Color;
34
35//////////////////////////////////////////////////////////////
36//
37// class AppearanceScheme
38//
39//////////////////////////////////////////////////////////////
40public class AppearanceScheme {
41        //     Color []baseSurfaceColors = {new Color(0, 180, 240), new Color(240, 180, 0), new Color(240, 0, 180),
42        //         new Color(0, 240, 180), new Color(180, 240, 0), new Color(180, 0, 240)};
43        Color[] baseSurfaceColors = { new Color(240, 160, 0),
44                        new Color(160, 240, 0), new Color(0, 160, 240),
45                        new Color(240, 0, 160), new Color(0, 240, 160),
46                        new Color(160, 0, 240) };
47
48        double surfaceIntensityFactor = 0.8;
49
50        Color[] baseCurveColors = { Color.black, Color.white };
51
52        double curveIntensityFactor = 0.7;
53
54        AppearanceScheme() {
55        }
56
57        public Color brighter(Color col, double factor, int no) {
58                try {
59                        Color tmpColor = new Color(
60                                        (int) (255 * (1 - (1 - col.getRed() / 255.0)
61                                                        * Math.pow(factor, no - 1))),
62                                        (int) (255 * (1 - (1 - col.getGreen() / 255.0)
63                                                        * Math.pow(factor, no - 1))),
64                                        (int) (255 * (1 - (1 - col.getBlue() / 255.0)
65                                                        * Math.pow(factor, no - 1))));
66                        //      System.out.println("col:"+col+",no"+no+", ---- newcol:"+tmpColor);
67                        return (tmpColor);
68                } catch (Exception ex) {
69                        return (col);
70                }
71        }
72
73        public Color darker(Color col, double factor, int no) {
74                try {
75                        Color tmpColor = new Color((int) (col.getRed() * Math.pow(factor,
76                                        no - 1)),
77                                        (int) (col.getGreen() * Math.pow(factor, no - 1)),
78                                        (int) (col.getBlue() * Math.pow(factor, no - 1)));
79                        //      System.out.println("col:"+col+",no"+no+", ---- newcol:"+tmpColor);
80                        return (tmpColor);
81                } catch (Exception ex) {
82                        return (col);
83                }
84        }
85
86        public Color getEquationColorInside(int no) {
87                return (brighter(baseSurfaceColors[(no - 1)
88                                % (baseSurfaceColors.length)], surfaceIntensityFactor,
89                                ((int) (no / (baseSurfaceColors.length))) * 3 + 2));
90        }
91
92        public Color getEquationColorOutside(int no) {
93                return (brighter(baseSurfaceColors[(no - 1)
94                                % (baseSurfaceColors.length)], surfaceIntensityFactor,
95                                ((int) (no / (baseSurfaceColors.length))) * 3 + 1));
96        }
97
98        public Color getCurveColor(int no) {
99                if (no % 2 == 1) {
100                        return (brighter(baseCurveColors[(no - 1) % 2],
101                                        curveIntensityFactor, ((int) ((no) / 2)) + 1));
102                } else {
103                        return (darker(baseCurveColors[(no - 1) % 2], curveIntensityFactor,
104                                        ((int) ((no - 1) / 2)) + 1));
105                }
106        }
107} // end class AppearanceScheme
108
Note: See TracBrowser for help on using the repository browser.