Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e8e8f9
commit 86a60cf
Showing
5 changed files
with
210 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.softwsgbj.hexnet.dw; | ||
|
||
import com.softwsgbj.hexnet.HexPoint; | ||
import com.softwsgbj.hexnet.Hexagon; | ||
import com.softwsgbj.hexnet.Map; | ||
|
||
public abstract class MapRender { | ||
|
||
private Map<?> m; | ||
private GeometricAdapter geo; | ||
|
||
public MapRender(Map<?> m){ | ||
this.m = m; | ||
this.geo = new GeometricAdapter(m); | ||
} | ||
|
||
public void repaintAll(){ | ||
|
||
} | ||
public void paint(int x, int y){ | ||
HexPoint p = m.buildPoint(x, y); | ||
if(p!= null){ | ||
Hexagon h = m.getHexagonIn(p); | ||
if(h != null){ | ||
|
||
} else { | ||
/*not exists*/ | ||
/*paint default hexagon*/ | ||
} | ||
|
||
} else { /* out of bounds*/ } | ||
} | ||
|
||
protected abstract void paint(HexDraw draw, int x, int y); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.softwsgbj.hexnet.dw; | ||
|
||
public class Metric implements Comparable<Metric>{ | ||
|
||
private GeoElements.NotableSegment reference_segment; | ||
private double value; | ||
|
||
public Metric(GeoElements.NotableSegment reference_segment, double value){ | ||
changeMetric(reference_segment, value); | ||
} | ||
|
||
public double getRadiusSize(){ | ||
return value*reference_segment.getRadiusProportion(); | ||
} | ||
public double getApothemSize(){ | ||
return getRadiusSize()*Math.cos(Math.PI/6.0); | ||
} | ||
public double getSizeOf(GeoElements.NotableSegment reference_segment){ | ||
double prev = getRadiusSize(); | ||
return prev / reference_segment.getRadiusProportion(); | ||
} | ||
public void changeMetric(GeoElements.NotableSegment reference_segment, double value){ | ||
if(value <= 0.0) | ||
throw new IllegalArgumentException("value must be positive."); | ||
this.reference_segment = reference_segment; | ||
this.value = value; | ||
} | ||
public boolean equals(Object o){ | ||
if(o!=null && o instanceof Metric){ | ||
Metric m = (Metric) o; | ||
return this.getRadiusSize() == m.getRadiusSize(); | ||
} else return false; | ||
} | ||
public int compareTo(Metric m){ | ||
double dif = getRadiusSize() - m.getRadiusSize(); | ||
if(dif > 0) return (int)Math.ceil(dif); | ||
else if(dif < 0) return (int) Math.ceil(-dif); | ||
else return 0; | ||
} | ||
} |