📄 mapcanvas.java
字号:
drawSegment(g, seg, lpx, lpy, div, 255);
} while(true);
if(m_gpsSegments != null)
drawSegment(g, m_gpsSegments, lpx, lpy, div, 65280);
drawDirectiontoWayPoint(g);
int offcenter = 0;
OneLoc sel = getSelectedItem(g, px, py + offcenter, zoom, dist, hasPointerEvents());
if(sel != null)
{
sel.paint(g, this);
sel.paintFull(g, this);
setSelectedLoc(sel);
} else
{
setSelectedLoc(null);
}
g.setFont(fontm);
drawTopIndicators(g, bottomLeft);
drawBottomIndicators(g, bottomLeft);
int maxLength = 10;
if(m_curSat < maps.length)
{
int l = g.getFont().stringWidth(maps[m_curSat]);
if(l > maxLength)
maxLength = l;
}
if(m_curSat < maps.length)
{
g.setColor(0xa0a0a0);
drawString(g, maps[m_curSat], 1, bottomLeft);
}
bottomLeft -= fonth;
if(m_displaySize)
{
int screensize = getSize(width);
int tmp = screensize;
int n;
for(n = 1; tmp / n > 10; n *= 10);
int fac = tmp / n;
if(fac > 4)
n *= 2;
else
if(fac == 1)
n /= 2;
int widthVis = (n * width) / tmp;
String unit = "";
if(n < 1000)
{
unit = " m";
} else
{
unit = " km";
n /= 1000;
}
g.setColor(0xffffff);
g.fillRect(0, (bottomLeft + fonth) - 4, widthVis + 2, 5);
g.setColor(0xff0000);
g.fillRect(1, (bottomLeft + fonth) - 3, widthVis, 3);
drawString(g, n + unit, 1, bottomLeft - 4);
bottomLeft -= fonth;
}
if(m_moreInfo != null)
{
drawString(g, m_moreInfo, 1, bottomLeft);
bottomLeft -= fonth;
}
if(m_lastLocation != null)
paintGPSPos(g, m_lastLocation, px, py, width, height, zoom);
if(zoomingMode)
{
int f;
if(zoom > requestedZoom)
f = 1 << zoom - requestedZoom;
else
f = 1 << -zoom + requestedZoom;
g.setColor(0);
int wf = width / f;
int hf = height / f;
g.drawRect((offx + zpx) - 1 - wf / 2, (offy + zpy) - 1 - hf / 2, wf, hf);
g.setColor(0xfffff);
g.drawRect((offx + zpx) - wf / 2, (offy + zpy) - hf / 2, wf, hf);
}
if(infoOnScreen != null)
drawInfo(g, infoOnScreen, 10, height - 50, 0, 0xffffff);
if(UtilMidp.DEBUG)
drawString(g, "Mem:" + Runtime.getRuntime().freeMemory(), 0, 90);
g.setFont(fontRef);
if(extendedMenu != null)
paintMenu(g, extendedMenu.getMenusItem());
g.setFont(fontm);
if(hasPointerEvents())
paintIcons(g);
if(m_drawConsumption)
{
int data = BufferImage.m_dataDownloadCounter / 1024;
String toDisp;
if(data > 900)
toDisp = data / 1024 + "." + ((data * 100) / 1024) % 100 + " Mb";
else
toDisp = data + " Kb";
drawString(g, toDisp, 10, tmpy);
tmpy += fonth + 1;
}
g.setClip(oldClipX, oldClipY, oldWidth, oldHeight);
}
public void setMode(int i)
{
}
public void drawTopIndicators(Graphics g1, int i)
{
}
public void drawBottomIndicators(Graphics g, int posy)
{
int pos = getWidth() - 10;
if(m_autoPositionningEnabeld)
{
pos -= g.getFont().stringWidth("GPS");
drawString(g, "GPS", pos, posy);
if(m_autoTrack)
{
pos -= g.getFont().stringWidth("TRACK/");
drawString(g, "TRACK/", pos, posy);
pos -= 4;
}
if(m_record)
{
g.setColor(0xff0000);
// g.drawString(curSavedTrack.toString(Track.currRecord), pos - fonth - 6, posy, 24);
if(m_pause)
{
g.fillRoundRect(pos - fonth - 4, posy, fonth, fonth, 5, 5);
g.setColor(0);
g.drawRoundRect(pos - fonth - 4, posy, fonth, fonth, 5, 5);
} else
{
g.fillTriangle(pos - fonth - 4, posy, pos - fonth - 4, posy + fonth, pos - 4, posy + fonth / 2);
g.drawLine(pos - fonth - 4, posy, pos - fonth - 4, posy + fonth);
g.drawLine(pos - fonth - 4, posy + fonth, pos - 4, posy + fonth / 2);
g.drawLine(pos - fonth - 4, posy, pos - 4, posy + fonth / 2);
}
}
}
}
public int getSize(int inOff)
{
Float f = Float.PI.Mul(0x615210L).Div(0x1000000L);
Float s = f.Mul(Float.cos(Float.toRadians(convLat(py + zoom * (height / 2)))));
int screensize = (int)s.Mul((1 << zoom) * inOff).toLong();
return screensize;
}
int dist(int dx, int dy)
{
long res = 0L;
long sqr2 = 179L;
if(dx < 0)
dx = -dx;
if(dy < 0)
dy = -dy;
long p = (dx <= dy ? dy : dx) << 8;
long p1 = (long)(dx + dy) * sqr2;
res = p >= p1 ? p1 : p;
res = (res * (256L + 0x10000L / (1024L - 2L * sqr2))) / 512L;
return (int)res;
}
public void drawSegment(Graphics g, int segment[], int lpx, int lpy, int div, int color)
{
int oldX = 0;
int oldY = 0;
g.setColor(color);
for(int i = 0; i < segment.length && segment[i] != -1; i += 2)
{
int x = segment[i + 1] / div - lpx;
int y = segment[i] / div - lpy;
if(i > 0)
{
int dist = dist(oldX - x, oldY - y);
if(dist == 0)
dist = 256;
if(dist < 0x10000)
{
int x1 = ((y - oldY) * 2 * 256) / dist;
int y1 = (-(x - oldX) * 2 * 256) / dist;
g.fillTriangle(oldX - x1, oldY - y1, x - x1, y - y1, x + x1, y + y1);
g.fillTriangle(oldX - x1, oldY - y1, oldX + x1, oldY + y1, x + x1, y + y1);
}
}
oldX = x;
oldY = y;
}
}
protected void drawInfo(Graphics g, String s, int px, int py, int col, int bcol)
{
int fwidth = g.getFont().stringWidth(s);
int fheight = g.getFont().getHeight();
px = (getWidth() - fwidth) / 2;
g.setColor(bcol);
g.fillRoundRect(px - 2, py - 2, fwidth + 4, fheight + 4, 5, 5);
g.setColor(col);
g.drawRoundRect(px - 2, py - 2, fwidth + 4, fheight + 4, 5, 5);
g.drawString(s, px, py, 20);
}
void drawImage(Graphics g, Image inIma, int px, int py, int offx, int offY, int sizeIn,
int sizeRes)
{
if(UtilMidp.DEBUG)
System.out.println("size:" + offx + " " + offY + " " + sizeIn);
if(inIma.getWidth() == 1)
return;
if(datas == null || datas.length != sizeIn)
datas = new int[sizeIn];
if(datad == null || datad.length != sizeRes)
datad = new int[sizeRes];
if(array == null || array.length != sizeRes)
array = new int[sizeRes];
for(int j = 0; j < sizeRes; j++)
array[j] = ((j * sizeIn) / sizeRes) % sizeIn;
int curLine = -1;
for(int i = 0; i < sizeRes; i++)
{
if(py + i < 0 || py + i >= height)
continue;
int line = offY + (i * sizeIn) / sizeRes;
if(line != curLine)
{
inIma.getRGB(datas, 0, sizeIn, offx, line, sizeIn, 1);
curLine = line;
for(int j = 0; j < sizeRes; j++)
datad[j] = datas[array[j]];
}
try
{
if(px < 0)
g.drawRGB(datad, -px, sizeRes, 0, py + i, sizeRes + px, 1, false);
else
g.drawRGB(datad, 0, sizeRes, px, py + i, sizeRes, 1, false);
}
catch(Exception e) { }
}
}
private void drawSquare(Graphics g, int x, int y, int px, int py, int zoom)
{
px -= px % sizeScr;
py -= py % sizeScr;
int numSat = (m_modeSat ? 1 : 0) + m_curSat * 2;
BufferImage imaBuff = BufferImage.getImage(px, py, zoom, numSat, sizeScr);
BufferImage imaBuffTmp = imaBuff;
int offX = 0;
int offY = 0;
int sizeSq = sizeScr;
int curZoom = zoom;
int oldPx = px;
int oldPy = py;
if(m_useResampledImages && System.currentTimeMillis() - lastZoomTimeStamp > 1000L)
{
for(; (imaBuff == null || imaBuff.ima == null) && curZoom < 17 && sizeSq > 1; sizeSq = (short)(sizeSq / 2))
{
curZoom++;
oldPx /= 2;
oldPy /= 2;
offX = offX / 2 + oldPx % sizeScr;
offY = offY / 2 + oldPy % sizeScr;
oldPx = (oldPx / sizeScr) * sizeScr;
oldPy = (oldPy / sizeScr) * sizeScr;
BufferImage buff = BufferImage.getImage(oldPx, oldPy, curZoom, numSat, sizeScr, false);
if(buff != null)
imaBuff = buff;
}
if(imaBuffTmp.ima == null && imaBuff != null && imaBuff.ima != null)
{
drawImage(g, imaBuff.ima, x, y, offX, offY, sizeSq, sizeScr);
return;
}
}
if(imaBuff != null && imaBuff.ima != null)
{
g.drawImage(imaBuff.ima, x, y, 20);
if(UtilMidp.DEBUG)
{
BufferImage _tmp = imaBuff;
drawString(g, "" + BufferImage.count, x, y);
}
if(imaBuff.state == 4)
{
g.setColor(0x800000);
g.fillRect(x, y, sizeScr, sizeScr);
drawString(g, "NOT AVAILABLE", x + 50, y + sizeScr / 2);
}
if(UtilMidp.DEBUG && imaBuff.debugString != null)
{
g.setColor(0xff0000);
g.drawString(imaBuff.debugString, x, y + 10, 20);
g.drawString("id:" + imaBuff.rmsId + " " + imaBuff.state, x, y + 20, 20);
}
} else
{
if(m_modeSat)
g.setColor(0, 0, 0);
else
g.setColor(255, 255, 255);
if(imaBuff != null && imaBuff.state == 2)
g.setColor(0x808080);
g.fillRect(x, y, sizeScr, sizeScr);
g.setColor(255, 0, 0);
g.drawLine(x, y, x + sizeScr, y + sizeScr);
g.drawLine(x, y + sizeScr, x + sizeScr, y);
g.drawLine(x, y, x + sizeScr, y);
g.drawLine(x, y, x, y + sizeScr);
if(imaBuff != null && imaBuff.state == 2)
drawString(g, "Loading...", x + 50, y + sizeScr / 2);
}
}
private void drawSquare(Graphics g, int x, int y, int px, int py, int zoom, boolean isOverlay)
{
px -= px % sizeScr;
py -= py % sizeScr;
int numSat = (m_modeSat ? 1 : 0) + m_curSat * 2;
BufferImage imaBuff = BufferImage.getImage(px, py, zoom, numSat, sizeScr);
BufferImage imaBuffTmp = imaBuff;
int offX = 0;
int offY = 0;
int sizeSq = sizeScr;
int curZoom = zoom;
int oldPx = px;
int oldPy = py;
if(m_useResampledImages && System.currentTimeMillis() - lastZoomTimeStamp > 1000L)
{
for(; (imaBuff == null || imaBuff.ima == null) && curZoom < 17 && sizeSq > 1; sizeSq = (short)(sizeSq / 2))
{
curZoom++;
oldPx /= 2;
oldPy /= 2;
offX = offX / 2 + oldPx % sizeScr;
offY = offY / 2 + oldPy % sizeScr;
oldPx = (oldPx / sizeScr) * sizeScr;
oldPy = (oldPy / sizeScr) * sizeScr;
BufferImage buff = BufferImage.getImage(oldPx, oldPy, curZoom, numSat, sizeScr, false);
if(buff != null)
imaBuff = buff;
}
if(imaBuffTmp.ima == null && imaBuff != null && imaBuff.ima != null)
{
drawImage(g, imaBuff.ima, x, y, offX, offY, sizeSq, sizeScr);
imaBuff.state = 1;
return;
}
}
if(imaBuff != null && imaBuff.ima != null)
{
g.drawImage(imaBuff.ima, x, y, 20);
if(UtilMidp.DEBUG)
{
BufferImage _tmp = imaBuff;
drawString(g, "" + BufferImage.count, x, y);
}
if(imaBuff.state == 4 && !isOverlay)
{
g.setColor(0x800000);
g.fillRect(x, y, sizeScr, sizeScr);
drawString(g, "NOT AVAILABLE", x + 50, y + sizeScr / 2);
}
if(UtilMidp.DEBUG && imaBuff.debugString != null)
{
g.setColor(0xff0000);
g.drawString(imaBuff.debugString, x, y + 10, 20);
g.drawString("id:" + imaBuff.rmsId + " " + imaBuff.state, x, y + 20, 20);
}
} else
if(!isOverlay)
{
if(m_modeSat)
g.setColor(0, 0, 0);
else
g.setColor(255, 255, 255);
if(imaBuff != null && imaBuff.state == 2)
g.setColor(0x808080);
g.fillRect(x, y, sizeScr, sizeScr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -