|
| 1 | +function marker = extractGeoMarker(geoData, axisData) |
| 2 | + |
| 3 | + %-------------------------------------------------------------------------% |
| 4 | + |
| 5 | + %-FIGURE STRUCTURE-% |
| 6 | + figureData = get(ancestor(geoData.Parent,'figure')); |
| 7 | + |
| 8 | + %-INITIALIZE OUTPUT-% |
| 9 | + marker = struct(); |
| 10 | + |
| 11 | + %-------------------------------------------------------------------------% |
| 12 | + |
| 13 | + %-MARKER SIZEREF-% |
| 14 | + marker.sizeref = 1; |
| 15 | + |
| 16 | + %-------------------------------------------------------------------------% |
| 17 | + |
| 18 | + %-MARKER SIZEMODE-% |
| 19 | + marker.sizemode = 'area'; |
| 20 | + |
| 21 | + %-------------------------------------------------------------------------% |
| 22 | + |
| 23 | + %-MARKER SIZE (STYLE)-% |
| 24 | + marker.size = geoData.SizeData; |
| 25 | + |
| 26 | + %-------------------------------------------------------------------------% |
| 27 | + |
| 28 | + %-MARKER SYMBOL (STYLE)-% |
| 29 | + if ~strcmp(geoData.Marker,'none') |
| 30 | + |
| 31 | + switch geoData.Marker |
| 32 | + case '.' |
| 33 | + marksymbol = 'circle'; |
| 34 | + case 'o' |
| 35 | + marksymbol = 'circle'; |
| 36 | + case 'x' |
| 37 | + marksymbol = 'x-thin-open'; |
| 38 | + case '+' |
| 39 | + marksymbol = 'cross-thin-open'; |
| 40 | + case '*' |
| 41 | + marksymbol = 'asterisk-open'; |
| 42 | + case {'s','square'} |
| 43 | + marksymbol = 'square'; |
| 44 | + case {'d','diamond'} |
| 45 | + marksymbol = 'diamond'; |
| 46 | + case 'v' |
| 47 | + marksymbol = 'triangle-down'; |
| 48 | + case '^' |
| 49 | + marksymbol = 'star-triangle-up'; |
| 50 | + case '<' |
| 51 | + marksymbol = 'triangle-left'; |
| 52 | + case '>' |
| 53 | + marksymbol = 'triangle-right'; |
| 54 | + case {'p','pentagram'} |
| 55 | + marksymbol = 'star'; |
| 56 | + case {'h','hexagram'} |
| 57 | + marksymbol = 'hexagram'; |
| 58 | + end |
| 59 | + |
| 60 | + marker.symbol = marksymbol; |
| 61 | + end |
| 62 | + |
| 63 | + %-------------------------------------------------------------------------% |
| 64 | + |
| 65 | + %-MARKER LINE WIDTH (STYLE)-% |
| 66 | + marker.line.width = 2*geoData.LineWidth; |
| 67 | + |
| 68 | + %-------------------------------------------------------------------------% |
| 69 | + |
| 70 | + %--MARKER FILL COLOR--% |
| 71 | + |
| 72 | + % marker face color |
| 73 | + faceColor = geoData.MarkerFaceColor; |
| 74 | + |
| 75 | + filledMarkerSet = {'o','square','s','diamond','d','v','^', '<','>','hexagram','pentagram'}; |
| 76 | + filledMarker = ismember(geoData.Marker, filledMarkerSet); |
| 77 | + |
| 78 | + if filledMarker |
| 79 | + |
| 80 | + if isnumeric(faceColor) |
| 81 | + markerColor = sprintf('rgb(%f,%f,%f)', 255 * faceColor); |
| 82 | + |
| 83 | + else |
| 84 | + |
| 85 | + switch faceColor |
| 86 | + |
| 87 | + case 'none' |
| 88 | + |
| 89 | + markerColor = 'rgba(0,0,0,0)'; |
| 90 | + |
| 91 | + case 'auto' |
| 92 | + |
| 93 | + if ~strcmp(axisData.Color,'none') |
| 94 | + col = 255*axisData.Color; |
| 95 | + else |
| 96 | + col = 255*figureData.Color; |
| 97 | + end |
| 98 | + |
| 99 | + markerColor = sprintf('rgb(%f,%f,%f)', col); |
| 100 | + |
| 101 | + case 'flat' |
| 102 | + |
| 103 | + cData = geoData.CData; |
| 104 | + cMap = figureData.Colormap; |
| 105 | + ncolors = size(cMap, 1); |
| 106 | + |
| 107 | + for m = 1:length(cData) |
| 108 | + colorValue = max( min( cData(m), axisData.CLim(2) ), axisData.CLim(1) ); |
| 109 | + scaleFactor = (colorValue - axisData.CLim(1)) / diff(axisData.CLim); |
| 110 | + rgbColor = 255 * cMap( 1+floor(scaleFactor*(ncolors-1)), : ); |
| 111 | + markerColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); |
| 112 | + end |
| 113 | + end |
| 114 | + end |
| 115 | + |
| 116 | + %-set marker color-% |
| 117 | + marker.color = markerColor; |
| 118 | + |
| 119 | + end |
| 120 | + |
| 121 | + %-------------------------------------------------------------------------% |
| 122 | + |
| 123 | + %-MARKER LINE COLOR-% |
| 124 | + |
| 125 | + % marker edge color |
| 126 | + edgeColor = geoData.MarkerEdgeColor; |
| 127 | + |
| 128 | + if isnumeric(edgeColor) |
| 129 | + lineColor = sprintf('rgb(%f,%f,%f)', 255 * edgeColor); |
| 130 | + |
| 131 | + else |
| 132 | + switch edgeColor |
| 133 | + |
| 134 | + case 'none' |
| 135 | + |
| 136 | + lineColor = 'rgba(0,0,0,0)'; |
| 137 | + |
| 138 | + case 'auto' |
| 139 | + |
| 140 | + % TODO |
| 141 | + |
| 142 | + case 'flat' |
| 143 | + |
| 144 | + cData = geoData.CData; |
| 145 | + cMap = figureData.Colormap; |
| 146 | + ncolors = size(cMap, 1); |
| 147 | + |
| 148 | + for m = 1:length(cData) |
| 149 | + colorValue = max( min( cData(m), axisData.CLim(2) ), axisData.CLim(1) ); |
| 150 | + scaleFactor = (colorValue - axisData.CLim(1)) / diff(axisData.CLim); |
| 151 | + rgbColor = 255 * cMap( 1+floor(scaleFactor*(ncolors-1)), : ); |
| 152 | + lineColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); |
| 153 | + end |
| 154 | + |
| 155 | + end |
| 156 | + end |
| 157 | + |
| 158 | + if filledMarker |
| 159 | + marker.line.color = lineColor; |
| 160 | + else |
| 161 | + marker.color = lineColor; |
| 162 | + end |
| 163 | + |
| 164 | + %-------------------------------------------------------------------------% |
| 165 | + |
| 166 | +end |
0 commit comments