提交 66aa2f8f 编写于 作者: S Skylot

fix issues reported by coverity and code style

上级 99d831c4
...@@ -10,7 +10,7 @@ public enum ResourceType { ...@@ -10,7 +10,7 @@ public enum ResourceType {
LIB(".so"), LIB(".so"),
UNKNOWN; UNKNOWN;
private String[] exts; private final String[] exts;
ResourceType(String... exts) { ResourceType(String... exts) {
this.exts = exts; this.exts = exts;
......
...@@ -28,7 +28,7 @@ public final class ResourcesLoader { ...@@ -28,7 +28,7 @@ public final class ResourcesLoader {
private static final int READ_BUFFER_SIZE = 8 * 1024; private static final int READ_BUFFER_SIZE = 8 * 1024;
private static final int LOAD_SIZE_LIMIT = 10 * 1024 * 1024; private static final int LOAD_SIZE_LIMIT = 10 * 1024 * 1024;
private JadxDecompiler jadxRef; private final JadxDecompiler jadxRef;
ResourcesLoader(JadxDecompiler jadxRef) { ResourcesLoader(JadxDecompiler jadxRef) {
this.jadxRef = jadxRef; this.jadxRef = jadxRef;
......
...@@ -162,10 +162,7 @@ public class ConditionGen extends InsnGen { ...@@ -162,10 +162,7 @@ public class ConditionGen extends InsnGen {
if (condition.isCompare()) { if (condition.isCompare()) {
return false; return false;
} }
if (condition.getMode() != Mode.NOT) { return condition.getMode() != Mode.NOT;
return true;
}
return false;
} }
private static boolean isArgWrapNeeded(InsnArg arg) { private static boolean isArgWrapNeeded(InsnArg arg) {
......
...@@ -10,7 +10,7 @@ import java.util.Map; ...@@ -10,7 +10,7 @@ import java.util.Map;
public class EnumMapAttr implements IAttribute { public class EnumMapAttr implements IAttribute {
public static class KeyValueMap { public static class KeyValueMap {
private Map<Object, Object> map = new HashMap<Object, Object>(); private final Map<Object, Object> map = new HashMap<Object, Object>();
public Object get(Object key) { public Object get(Object key) {
return map.get(key); return map.get(key);
...@@ -21,7 +21,7 @@ public class EnumMapAttr implements IAttribute { ...@@ -21,7 +21,7 @@ public class EnumMapAttr implements IAttribute {
} }
} }
private Map<FieldNode, KeyValueMap> fieldsMap = new HashMap<FieldNode, KeyValueMap>(); private final Map<FieldNode, KeyValueMap> fieldsMap = new HashMap<FieldNode, KeyValueMap>();
public KeyValueMap getMap(FieldNode field) { public KeyValueMap getMap(FieldNode field) {
return fieldsMap.get(field); return fieldsMap.get(field);
......
...@@ -32,9 +32,9 @@ public class AccessInfo { ...@@ -32,9 +32,9 @@ public class AccessInfo {
} }
public AccessInfo getVisibility() { public AccessInfo getVisibility() {
int f = (accFlags & AccessFlags.ACC_PUBLIC) int f = accFlags & AccessFlags.ACC_PUBLIC
| (accFlags & AccessFlags.ACC_PROTECTED) | accFlags & AccessFlags.ACC_PROTECTED
| (accFlags & AccessFlags.ACC_PRIVATE); | accFlags & AccessFlags.ACC_PRIVATE;
return new AccessInfo(f, type); return new AccessInfo(f, type);
} }
......
...@@ -111,16 +111,9 @@ public final class MethodInfo { ...@@ -111,16 +111,9 @@ public final class MethodInfo {
return false; return false;
} }
MethodInfo other = (MethodInfo) obj; MethodInfo other = (MethodInfo) obj;
if (!shortId.equals(other.shortId)) { return shortId.equals(other.shortId)
return false; && retType.equals(other.retType)
} && declClass.equals(other.declClass);
if (!retType.equals(other.retType)) {
return false;
}
if (!declClass.equals(other.declClass)) {
return false;
}
return true;
} }
@Override @Override
......
...@@ -47,7 +47,7 @@ public final class LiteralArg extends InsnArg { ...@@ -47,7 +47,7 @@ public final class LiteralArg extends InsnArg {
@Override @Override
public int hashCode() { public int hashCode() {
return (int) (literal ^ (literal >>> 32)) + 31 * getType().hashCode(); return (int) (literal ^ literal >>> 32) + 31 * getType().hashCode();
} }
@Override @Override
......
package jadx.core.dex.instructions.args; package jadx.core.dex.instructions.args;
import org.jetbrains.annotations.NotNull;
public class TypeImmutableArg extends RegisterArg { public class TypeImmutableArg extends RegisterArg {
private boolean isThis; private boolean isThis;
...@@ -36,7 +38,7 @@ public class TypeImmutableArg extends RegisterArg { ...@@ -36,7 +38,7 @@ public class TypeImmutableArg extends RegisterArg {
} }
@Override @Override
void setSVar(SSAVar sVar) { void setSVar(@NotNull SSAVar sVar) {
if (isThis) { if (isThis) {
sVar.setName("this"); sVar.setName("this");
} }
......
...@@ -282,7 +282,7 @@ public class ClassNode extends LineAttrNode implements ILoadable { ...@@ -282,7 +282,7 @@ public class ClassNode extends LineAttrNode implements ILoadable {
field = cn.constFields.get(obj); field = cn.constFields.get(obj);
} }
while (field == null while (field == null
&& (cn.clsInfo.getParentClass() != null) && cn.clsInfo.getParentClass() != null
&& (cn = dex.resolveClass(cn.clsInfo.getParentClass())) != null); && (cn = dex.resolveClass(cn.clsInfo.getParentClass())) != null);
if (field == null && searchGlobal) { if (field == null && searchGlobal) {
......
...@@ -74,7 +74,8 @@ public class InsnNode extends LineAttrNode { ...@@ -74,7 +74,8 @@ public class InsnNode extends LineAttrNode {
public boolean containsArg(RegisterArg arg) { public boolean containsArg(RegisterArg arg) {
for (InsnArg a : arguments) { for (InsnArg a : arguments) {
if (a == arg || (a.isRegister() && ((RegisterArg) a).getRegNum() == arg.getRegNum())) { if (a == arg
|| a.isRegister() && ((RegisterArg) a).getRegNum() == arg.getRegNum()) {
return true; return true;
} }
} }
......
...@@ -75,8 +75,8 @@ public class MethodNode extends LineAttrNode implements ILoadable { ...@@ -75,8 +75,8 @@ public class MethodNode extends LineAttrNode implements ILoadable {
this.mthInfo = MethodInfo.fromDex(classNode.dex(), mthData.getMethodIndex()); this.mthInfo = MethodInfo.fromDex(classNode.dex(), mthData.getMethodIndex());
this.parentClass = classNode; this.parentClass = classNode;
this.accFlags = new AccessInfo(mthData.getAccessFlags(), AFType.METHOD); this.accFlags = new AccessInfo(mthData.getAccessFlags(), AFType.METHOD);
this.noCode = (mthData.getCodeOffset() == 0); this.noCode = mthData.getCodeOffset() == 0;
this.methodData = (noCode ? null : mthData); this.methodData = noCode ? null : mthData;
} }
@Override @Override
...@@ -527,7 +527,7 @@ public class MethodNode extends LineAttrNode implements ILoadable { ...@@ -527,7 +527,7 @@ public class MethodNode extends LineAttrNode implements ILoadable {
defaultArgCount = 1; defaultArgCount = 1;
} }
} }
result = (argsList == null) || (argsList.size() == defaultArgCount); result = argsList == null || argsList.size() == defaultArgCount;
} }
return result; return result;
} }
......
...@@ -149,7 +149,7 @@ public class DebugInfoParser { ...@@ -149,7 +149,7 @@ public class DebugInfoParser {
int adjustedOpcode = c - DBG_FIRST_SPECIAL; int adjustedOpcode = c - DBG_FIRST_SPECIAL;
int addrInc = adjustedOpcode / DBG_LINE_RANGE; int addrInc = adjustedOpcode / DBG_LINE_RANGE;
addr = addrChange(addr, addrInc, line); addr = addrChange(addr, addrInc, line);
line += DBG_LINE_BASE + (adjustedOpcode % DBG_LINE_RANGE); line += DBG_LINE_BASE + adjustedOpcode % DBG_LINE_RANGE;
setLine(addr, line); setLine(addr, line);
} else { } else {
throw new DecodeException("Unknown debug insn code: " + c); throw new DecodeException("Unknown debug insn code: " + c);
...@@ -263,8 +263,8 @@ public class DebugInfoParser { ...@@ -263,8 +263,8 @@ public class DebugInfoParser {
int localStart = var.getStartAddr(); int localStart = var.getStartAddr();
int localEnd = var.getEndAddr(); int localEnd = var.getEndAddr();
boolean isIntersected = !((localEnd < ssaStart) || (ssaEnd < localStart)); boolean isIntersected = !(localEnd < ssaStart || ssaEnd < localStart);
if (isIntersected && (ssaEnd <= localEnd)) { if (isIntersected && ssaEnd <= localEnd) {
mergeRequired = true; mergeRequired = true;
} }
} else { } else {
......
...@@ -210,7 +210,7 @@ public class CodeShrinker extends AbstractVisitor { ...@@ -210,7 +210,7 @@ public class CodeShrinker extends AbstractVisitor {
// } // }
SSAVar sVar = arg.getSVar(); SSAVar sVar = arg.getSVar();
// allow inline only one use arg or 'this' // allow inline only one use arg or 'this'
if (sVar == null || (sVar.getVariableUseCount() != 1 && !arg.isThis())) { if (sVar == null || sVar.getVariableUseCount() != 1 && !arg.isThis()) {
continue; continue;
} }
InsnNode assignInsn = sVar.getAssign().getParentInsn(); InsnNode assignInsn = sVar.getAssign().getParentInsn();
......
...@@ -249,7 +249,7 @@ public class SimplifyVisitor extends AbstractVisitor { ...@@ -249,7 +249,7 @@ public class SimplifyVisitor extends AbstractVisitor {
} }
InsnNode wrap = ((InsnWrapArg) arg).getWrapInsn(); InsnNode wrap = ((InsnWrapArg) arg).getWrapInsn();
InsnType wrapType = wrap.getType(); InsnType wrapType = wrap.getType();
if ((wrapType != InsnType.ARITH && wrapType != InsnType.STR_CONCAT) if (wrapType != InsnType.ARITH && wrapType != InsnType.STR_CONCAT
|| !wrap.getArg(0).isInsnWrap()) { || !wrap.getArg(0).isInsnWrap()) {
return null; return null;
} }
......
...@@ -194,7 +194,7 @@ public class BlockSplitter extends AbstractVisitor { ...@@ -194,7 +194,7 @@ public class BlockSplitter extends AbstractVisitor {
private static boolean isDoWhile(Map<Integer, BlockNode> blocksMap, BlockNode curBlock, InsnNode insn) { private static boolean isDoWhile(Map<Integer, BlockNode> blocksMap, BlockNode curBlock, InsnNode insn) {
// split 'do-while' block (last instruction: 'if', target this block) // split 'do-while' block (last instruction: 'if', target this block)
if (insn.getType() == InsnType.IF) { if (insn.getType() == InsnType.IF) {
IfNode ifs = (IfNode) (insn); IfNode ifs = (IfNode) insn;
BlockNode targetBlock = blocksMap.get(ifs.getTarget()); BlockNode targetBlock = blocksMap.get(ifs.getTarget());
if (targetBlock == curBlock) { if (targetBlock == curBlock) {
return true; return true;
......
...@@ -195,7 +195,7 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor ...@@ -195,7 +195,7 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor
CodeShrinker.shrinkMethod(mth); CodeShrinker.shrinkMethod(mth);
if (arrGetInsn.contains(AFlag.WRAPPED)) { if (arrGetInsn.contains(AFlag.WRAPPED)) {
InsnArg wrapArg = BlockUtils.searchWrappedInsnParent(mth, arrGetInsn); InsnArg wrapArg = BlockUtils.searchWrappedInsnParent(mth, arrGetInsn);
if (wrapArg != null) { if (wrapArg != null && wrapArg.getParentInsn() != null) {
wrapArg.getParentInsn().replaceArg(wrapArg, iterVar); wrapArg.getParentInsn().replaceArg(wrapArg, iterVar);
} else { } else {
LOG.debug(" checkArrayForEach: Wrapped insn not found: {}, mth: {}", arrGetInsn, mth); LOG.debug(" checkArrayForEach: Wrapped insn not found: {}, mth: {}", arrGetInsn, mth);
...@@ -233,7 +233,7 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor ...@@ -233,7 +233,7 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor
RegisterArg iterVar = nextCall.getResult(); RegisterArg iterVar = nextCall.getResult();
if (nextCall.contains(AFlag.WRAPPED)) { if (nextCall.contains(AFlag.WRAPPED)) {
InsnArg wrapArg = BlockUtils.searchWrappedInsnParent(mth, nextCall); InsnArg wrapArg = BlockUtils.searchWrappedInsnParent(mth, nextCall);
if (wrapArg != null) { if (wrapArg != null && wrapArg.getParentInsn() != null) {
InsnNode parentInsn = wrapArg.getParentInsn(); InsnNode parentInsn = wrapArg.getParentInsn();
if (parentInsn.getType() != InsnType.CHECK_CAST) { if (parentInsn.getType() != InsnType.CHECK_CAST) {
parentInsn.replaceArg(wrapArg, iterVar); parentInsn.replaceArg(wrapArg, iterVar);
......
...@@ -203,7 +203,7 @@ public class RegionMaker { ...@@ -203,7 +203,7 @@ public class RegionMaker {
BlockNode out; BlockNode out;
if (loopRegion.isConditionAtEnd()) { if (loopRegion.isConditionAtEnd()) {
BlockNode thenBlock = condInfo.getThenBlock(); BlockNode thenBlock = condInfo.getThenBlock();
out = (thenBlock == loopStart ? condInfo.getElseBlock() : thenBlock); out = thenBlock == loopStart ? condInfo.getElseBlock() : thenBlock;
loopStart.remove(AType.LOOP); loopStart.remove(AType.LOOP);
loop.getEnd().add(AFlag.SKIP); loop.getEnd().add(AFlag.SKIP);
stack.addExit(loop.getEnd()); stack.addExit(loop.getEnd());
...@@ -922,13 +922,7 @@ public class RegionMaker { ...@@ -922,13 +922,7 @@ public class RegionMaker {
if (b1 == null || b2 == null) { if (b1 == null || b2 == null) {
return false; return false;
} }
if (isReturnBlocks(b1, b2)) { return isReturnBlocks(b1, b2) || isSyntheticPath(b1, b2);
return true;
}
if (isSyntheticPath(b1, b2)) {
return true;
}
return false;
} }
private static boolean isSyntheticPath(BlockNode b1, BlockNode b2) { private static boolean isSyntheticPath(BlockNode b1, BlockNode b2) {
......
...@@ -103,7 +103,7 @@ public class DebugUtils { ...@@ -103,7 +103,7 @@ public class DebugUtils {
} }
for (InsnArg arg : insn.getArguments()) { for (InsnArg arg : insn.getArguments()) {
if (arg instanceof RegisterArg) { if (arg instanceof RegisterArg) {
checkSSAVar(mth, insn, ((RegisterArg) arg)); checkSSAVar(mth, insn, (RegisterArg) arg);
} }
} }
} }
...@@ -131,7 +131,7 @@ public class DebugUtils { ...@@ -131,7 +131,7 @@ public class DebugUtils {
List<PhiInsn> phis = new ArrayList<PhiInsn>(); List<PhiInsn> phis = new ArrayList<PhiInsn>();
for (InsnNode insn : block.getInstructions()) { for (InsnNode insn : block.getInstructions()) {
if (insn.getType() == InsnType.PHI) { if (insn.getType() == InsnType.PHI) {
PhiInsn phi = ((PhiInsn) insn); PhiInsn phi = (PhiInsn) insn;
phis.add(phi); phis.add(phi);
if (phi.getArgsCount() != phi.getBlockBinds().size()) { if (phi.getArgsCount() != phi.getBlockBinds().size()) {
throw new JadxRuntimeException("Incorrect args and binds in PHI"); throw new JadxRuntimeException("Incorrect args and binds in PHI");
......
...@@ -189,7 +189,7 @@ public class RegionUtils { ...@@ -189,7 +189,7 @@ public class RegionUtils {
for (IContainer b : r.getSubBlocks()) { for (IContainer b : r.getSubBlocks()) {
// process try block // process try block
CatchAttr cb = b.get(AType.CATCH_BLOCK); CatchAttr cb = b.get(AType.CATCH_BLOCK);
if (cb != null && (b instanceof IRegion)) { if (cb != null && b instanceof IRegion) {
TryCatchBlock tb = cb.getTryBlock(); TryCatchBlock tb = cb.getTryBlock();
for (ExceptionHandler eh : tb.getHandlers()) { for (ExceptionHandler eh : tb.getHandlers()) {
if (isRegionContainsRegion(eh.getHandlerRegion(), region)) { if (isRegionContainsRegion(eh.getHandlerRegion(), region)) {
......
...@@ -85,6 +85,9 @@ public class Utils { ...@@ -85,6 +85,9 @@ public class Utils {
} }
public static String getStackTrace(Throwable throwable) { public static String getStackTrace(Throwable throwable) {
if (throwable == null) {
return "";
}
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true); PrintWriter pw = new PrintWriter(sw, true);
throwable.printStackTrace(pw); throwable.printStackTrace(pw);
...@@ -92,6 +95,6 @@ public class Utils { ...@@ -92,6 +95,6 @@ public class Utils {
} }
public static int compare(int x, int y) { public static int compare(int x, int y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1); return x < y ? -1 : x == y ? 0 : 1;
} }
} }
...@@ -209,7 +209,7 @@ public class BinaryXMLParser extends CommonBinaryParser { ...@@ -209,7 +209,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
for (int i = 0; i < attributeCount; i++) { for (int i = 0; i < attributeCount; i++) {
parseAttribute(i); parseAttribute(i);
writer.add('"'); writer.add('"');
if ((i + 1) < attributeCount) { if (i + 1 < attributeCount) {
writer.add(" "); writer.add(" ");
} }
} }
...@@ -267,7 +267,7 @@ public class BinaryXMLParser extends CommonBinaryParser { ...@@ -267,7 +267,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
} }
} else { } else {
String str = valuesParser.decodeValue(attrValDataType, attrValData); String str = valuesParser.decodeValue(attrValDataType, attrValData);
writer.add(str); writer.add(str != null ? str : "null");
} }
} }
......
...@@ -61,7 +61,7 @@ public class CommonBinaryParser extends ParserConstants { ...@@ -61,7 +61,7 @@ public class CommonBinaryParser extends ParserConstants {
return ""; return "";
} }
if ((len & 0x80) != 0) { if ((len & 0x80) != 0) {
len = ((len & 0x7F) << 8) | (strArray[start++] & 0xFF); len = (len & 0x7F) << 8 | strArray[start++] & 0xFF;
} }
byte[] arr = Arrays.copyOfRange(strArray, start, start + len); byte[] arr = Arrays.copyOfRange(strArray, start, start + len);
return new String(arr, ParserStream.STRING_CHARSET_UTF8); return new String(arr, ParserStream.STRING_CHARSET_UTF8);
......
...@@ -49,9 +49,16 @@ public class ManifestAttributes { ...@@ -49,9 +49,16 @@ public class ManifestAttributes {
private final Map<String, MAttr> attrMap = new HashMap<String, MAttr>(); private final Map<String, MAttr> attrMap = new HashMap<String, MAttr>();
public ManifestAttributes() throws Exception { public ManifestAttributes() throws Exception {
InputStream xmlStream = ManifestAttributes.class.getResourceAsStream(MANIFEST_ATTR_XML); InputStream xmlStream = null;
DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); try {
doc = dBuilder.parse(xmlStream); xmlStream = ManifestAttributes.class.getResourceAsStream(MANIFEST_ATTR_XML);
DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = dBuilder.parse(xmlStream);
} finally {
if (xmlStream != null) {
xmlStream.close();
}
}
} }
public void parse() { public void parse() {
......
...@@ -150,11 +150,11 @@ public class ParserConstants { ...@@ -150,11 +150,11 @@ public class ParserConstants {
protected static final int ATTR_MANY = ResMakeInternal(9); protected static final int ATTR_MANY = ResMakeInternal(9);
private static int ResMakeInternal(int entry) { private static int ResMakeInternal(int entry) {
return 0x01000000 | (entry & 0xFFFF); return 0x01000000 | entry & 0xFFFF;
} }
protected static boolean isResInternalId(int resid) { protected static boolean isResInternalId(int resid) {
return ((resid & 0xFFFF0000) != 0 && (resid & 0xFF0000) == 0); return (resid & 0xFFFF0000) != 0 && (resid & 0xFF0000) == 0;
} }
// Bit mask of allowed types, for use with ATTR_TYPE. // Bit mask of allowed types, for use with ATTR_TYPE.
......
...@@ -34,7 +34,7 @@ public class ParserStream { ...@@ -34,7 +34,7 @@ public class ParserStream {
readPos += 2; readPos += 2;
int b1 = input.read(); int b1 = input.read();
int b2 = input.read(); int b2 = input.read();
return (b2 & 0xFF) << 8 | (b1 & 0xFF); return (b2 & 0xFF) << 8 | b1 & 0xFF;
} }
public int readInt32() throws IOException { public int readInt32() throws IOException {
...@@ -44,7 +44,7 @@ public class ParserStream { ...@@ -44,7 +44,7 @@ public class ParserStream {
int b2 = in.read(); int b2 = in.read();
int b3 = in.read(); int b3 = in.read();
int b4 = in.read(); int b4 = in.read();
return b4 << 24 | (b3 & 0xFF) << 16 | (b2 & 0xFF) << 8 | (b1 & 0xFF); return b4 << 24 | (b3 & 0xFF) << 16 | (b2 & 0xFF) << 8 | b1 & 0xFF;
} }
public long readUInt32() throws IOException { public long readUInt32() throws IOException {
......
...@@ -113,8 +113,8 @@ public class ValuesParser extends ParserConstants { ...@@ -113,8 +113,8 @@ public class ValuesParser extends ParserConstants {
} }
private String decodeComplex(int data, boolean isFraction) { private String decodeComplex(int data, boolean isFraction) {
double value = (data & (COMPLEX_MANTISSA_MASK << COMPLEX_MANTISSA_SHIFT)) double value = (data & COMPLEX_MANTISSA_MASK << COMPLEX_MANTISSA_SHIFT)
* RADIX_MULTS[(data >> COMPLEX_RADIX_SHIFT) & COMPLEX_RADIX_MASK]; * RADIX_MULTS[data >> COMPLEX_RADIX_SHIFT & COMPLEX_RADIX_MASK];
int unitType = data & COMPLEX_UNIT_MASK; int unitType = data & COMPLEX_UNIT_MASK;
String unit; String unit;
if (isFraction) { if (isFraction) {
......
...@@ -13,6 +13,7 @@ import javax.swing.text.BadLocationException; ...@@ -13,6 +13,7 @@ import javax.swing.text.BadLocationException;
import javax.swing.text.Caret; import javax.swing.text.Caret;
import javax.swing.text.DefaultCaret; import javax.swing.text.DefaultCaret;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
...@@ -135,9 +136,13 @@ class ContentArea extends RSyntaxTextArea { ...@@ -135,9 +136,13 @@ class ContentArea extends RSyntaxTextArea {
return; return;
} }
int extentHeight = viewport.getExtentSize().height; int extentHeight = viewport.getExtentSize().height;
int viewHeight = viewport.getViewSize().height; Dimension viewSize = viewport.getViewSize();
if (viewSize == null) {
return;
}
int viewHeight = viewSize.height;
int y = Math.max(0, r.y - (extentHeight / 2)); int y = Math.max(0, r.y - extentHeight / 2);
y = Math.min(y, viewHeight - extentHeight); y = Math.min(y, viewHeight - extentHeight);
viewport.setViewPosition(new Point(0, y)); viewport.setViewPosition(new Point(0, y));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册