001/** 002 * Copyright (c) 2011, The University of Southampton and the individual contributors. 003 * All rights reserved. 004 * 005 * Redistribution and use in source and binary forms, with or without modification, 006 * are permitted provided that the following conditions are met: 007 * 008 * * Redistributions of source code must retain the above copyright notice, 009 * this list of conditions and the following disclaimer. 010 * 011 * * Redistributions in binary form must reproduce the above copyright notice, 012 * this list of conditions and the following disclaimer in the documentation 013 * and/or other materials provided with the distribution. 014 * 015 * * Neither the name of the University of Southampton nor the names of its 016 * contributors may be used to endorse or promote products derived from this 017 * software without specific prior written permission. 018 * 019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 022 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 023 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 026 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030package org.openimaj.vis.ternary; 031 032import java.text.AttributedCharacterIterator.Attribute; 033import java.util.HashMap; 034import java.util.Map; 035 036import org.openimaj.image.colour.ColourMap; 037import org.openimaj.image.colour.RGBColour; 038import org.openimaj.image.typography.FontStyle; 039import org.openimaj.image.typography.general.GeneralFont; 040import org.openimaj.image.typography.mathml.MathMLFont; 041 042/** 043 * 044 * @author Sina Samangooei (ss@ecs.soton.ac.uk) 045 */ 046public class TernaryParams extends HashMap<String, Object> { 047 /** 048 * 049 */ 050 public TernaryParams() { 051 this.put(COLOUR_MAP, ColourMap.Greys3); 052 this.put(BG_COLOUR, RGBColour.BLACK); 053 this.put(PADDING, 0); 054 Map<Attribute, Object> fontAttrs = new HashMap<Attribute, Object>(); 055 fontAttrs.put(FontStyle.FONT, new GeneralFont("Arial", 16)); 056 fontAttrs.put(FontStyle.FONT_SIZE, 16); 057 fontAttrs.put(FontStyle.HORIZONTAL_ALIGNMENT, FontStyle.HorizontalAlignment.HORIZONTAL_CENTER); 058 059 this.put(LABEL_FONT, fontAttrs); 060 this.put(TRIANGLE_BORDER, false); 061 this.put(TRIANGLE_BORDER_THICKNESS, 3); 062 this.put(TRIANGLE_BORDER_TICK_THICKNESS, 2); 063 this.put(TRIANGLE_BORDER_TICKS, false); 064 this.put(TRIANGLE_BORDER_COLOUR, RGBColour.BLACK); 065 this.put(DRAW_SCALE, false); 066 067 fontAttrs = new HashMap<Attribute, Object>(); 068 fontAttrs.put(FontStyle.FONT, new GeneralFont("Arial", 16)); 069 fontAttrs.put(FontStyle.FONT_SIZE, 16); 070 fontAttrs.put(FontStyle.COLOUR, RGBColour.BLACK); 071 fontAttrs.put(FontStyle.HORIZONTAL_ALIGNMENT, FontStyle.HorizontalAlignment.HORIZONTAL_RIGHT); 072 fontAttrs.put(FontStyle.VERTICAL_ALIGNMENT, FontStyle.VerticalAlignment.VERTICAL_TOP); 073 this.put(SCALE_FONT, fontAttrs); 074 this.put(SCALE_MIN, "min"); 075 this.put(SCALE_MAX, "max"); 076 fontAttrs = new HashMap<Attribute, Object>(); 077 fontAttrs.put(FontStyle.FONT, new MathMLFont()); 078 fontAttrs.put(FontStyle.FONT_SIZE, 12); 079 fontAttrs.put(FontStyle.COLOUR, RGBColour.BLACK); 080 fontAttrs.put(FontStyle.HORIZONTAL_ALIGNMENT, FontStyle.HorizontalAlignment.HORIZONTAL_CENTER); 081 fontAttrs.put(FontStyle.VERTICAL_ALIGNMENT, FontStyle.VerticalAlignment.VERTICAL_TOP); 082 this.put(TICK_FONT, fontAttrs); 083 this.put(LABEL_BACKGROUND, null); 084 this.put(LABEL_BORDER, null); 085 this.put(LABEL_PADDING, 0); 086 } 087 088 /** 089 * 090 */ 091 private static final long serialVersionUID = -1188907996988444966L; 092 /** 093 * 094 */ 095 public static final String COLOUR_MAP = "ternary.colour.map"; 096 /** 097 * 098 */ 099 public static final String PADDING = "ternary.border"; 100 /** 101 * 102 */ 103 public static final String LABELS = "ternary.label.data"; 104 /** 105 * 106 */ 107 public static final String LABEL_FONT = "ternary.label.font"; 108 109 /** 110 * 111 */ 112 public static final String LABEL_BACKGROUND = "ternary.label.background"; 113 114 /** 115 * 116 */ 117 public static final String LABEL_BORDER = "ternary.label.border"; 118 /** 119 * 120 */ 121 public static final String LABEL_PADDING = "ternary.label.padding"; 122 /** 123 * 124 */ 125 public static final String BG_COLOUR = "ternary.bg.colour"; 126 /** 127 * 128 */ 129 public static final String TRIANGLE_BORDER = "ternary.triangle_border.on"; 130 /** 131 * 132 */ 133 public static final String TRIANGLE_BORDER_THICKNESS = "ternary.triangle_border.thickness"; 134 /** 135 * 136 */ 137 public static final String TRIANGLE_BORDER_TICKS = "ternary.triangle_border.ticks"; 138 /** 139 * 140 */ 141 public static final String TRIANGLE_BORDER_COLOUR = "ternary.triangle_border.colour"; 142 /** 143 * 144 */ 145 public static final String TRIANGLE_BORDER_TICK_THICKNESS = "ternary.triangle_border.ticks.thickness"; 146 147 /** 148 * 149 */ 150 public static final String TICK_FONT = "ternary.triangle_border.ticks.font"; 151 /** 152 * 153 */ 154 public static final String DRAW_SCALE = "ternary.scale.draw"; 155 public static final float TOP_RIGHT_X = 0.9f; 156 public static final float TOP_RIGHT_Y = 0.0f; 157 public static final String SCALE_FONT = "ternary.scale.font"; 158 public static final String SCALE_MIN = "ternary.scale.min.text"; 159 public static final String SCALE_MAX = "ternary.scale.max.text"; 160 161 162 163 /** 164 * @param param 165 * @return the entry 166 */ 167 @SuppressWarnings("unchecked") 168 public <T> T getTyped(String param) { 169 return (T) this.get(param); 170 } 171 172}