id
int64
1
194k
buggy
stringlengths
23
37.5k
fixed
stringlengths
6
37.4k
193,501
public static boolean isConnected() { NetworkInfo info = getActiveNetworkInfo(); return info != null && info.isConnected(); } public static boolean isAvailableByPing() { <BUG>ShellUtils.CommandResult result = ShellUtils.execCmd("ping -c 1 -w 1 123.125.114.144", false); </BUG> boolean ret = result.result == 0; if (result.errorMsg != null) { LogUtils.d("isAvailableByPing errorMsg", result.errorMsg);
public static boolean isConnected() { NetworkInfo info = getActiveNetworkInfo(); return info != null && info.isConnected(); } public static boolean isAvailableByPing() { ShellUtils.CommandResult result = ShellUtils.execCmd("ping -c 1 -w 1 223.5.5.5", false); boolean ret = result.result == 0; if (result.errorMsg != null) { LogUtils.d("isAvailableByPing errorMsg", result.errorMsg);
193,502
StringBuilder sb = new StringBuilder(); sb.append("卡通doge的表情大集合,喜爱doge的朋友的福利到了,花了大半天的时间整理出来的狗东西,就被你们这么轻而易举地拿走了,现附上QQ表情包链接[doge-expression.eif](https://github.com/Blankj/doge-expression/blob/master/doge-expression.eif)(进去点击Download即可)\n\n"); </BUG> sb.append("下面展示doge各种姿势,请系好安全带,开车啦,滴滴滴~~\n\n"); <BUG>File file = new File("F:/MyGithub/doge-expression/expression"); List<File> files = FileUtils.listFilesInDir(file); </BUG> for (File f : files) { String name = f.getName(); sb.append("![")
StringBuilder sb = new StringBuilder(); sb.append("卡通doge的表情大集合,喜爱doge的朋友的福利到了,花了很多的时间整理出来的狗东西,就被你们这么轻而易举地拿走了,现附上QQ表情包链接[doge-expression.eif](https://raw.githubusercontent.com/Blankj/doge-expression/master/doge-expression.eif)(进去点击Download即可)\n\n"); sb.append("下面展示doge各种姿势,请系好安全带,开车啦,滴滴滴~~\n\n"); for (int i = 0; i < dogeFiles.size(); ++i) { List<File> files = FileUtils.listFilesInDir(dogeFiles.get(i)); for (File f : files) { String name = f.getName(); sb.append("![")
193,503
for (File f : files) { String name = f.getName(); sb.append("![") .append(name) .append("]") <BUG>.append("(https://github.com/Blankj/doge-expression/raw/master/expression/") .append(name) .append(") \n"); }</BUG> FileUtils.writeFileFromString("F:/MyGithub/doge-expression/README.md", sb.toString(), false);
for (File f : files) { String name = f.getName(); sb.append("![") .append(name) .append("]") .append("(https://github.com/Blankj/doge-expression/raw/master/") .append(f.getParentFile().getName()) .append("/") .append(name) .append(") \n");
193,504
if (strArray.length >= 5) { return strArray[1].replace("/.android_secure", "") + File.separator; } } if (p.waitFor() != 0 && p.exitValue() == 1) { <BUG>return " 命令执行失败"; }</BUG> } } catch (Exception e) { e.printStackTrace();
if (strArray.length >= 5) { return strArray[1].replace("/.android_secure", "") + File.separator; } } if (p.waitFor() != 0 && p.exitValue() == 1) { break; } } } catch (Exception e) { e.printStackTrace();
193,505
TextView tvAboutDevice = (TextView) findViewById(R.id.tv_about_device); findViewById(R.id.btn_shutdown).setOnClickListener(this); findViewById(R.id.btn_reboot).setOnClickListener(this); findViewById(R.id.btn_reboot_to_recovery).setOnClickListener(this); findViewById(R.id.btn_reboot_to_bootloader).setOnClickListener(this); <BUG>tvAboutDevice.setText("isRoot: " + DeviceUtils.isDeviceRoot() </BUG> + "\ngetSDKVersion: " + DeviceUtils.getSDKVersion() + "\ngetAndroidID: " + DeviceUtils.getAndroidID() + "\ngetMacAddress: " + DeviceUtils.getMacAddress()
TextView tvAboutDevice = (TextView) findViewById(R.id.tv_about_device); findViewById(R.id.btn_shutdown).setOnClickListener(this); findViewById(R.id.btn_reboot).setOnClickListener(this); findViewById(R.id.btn_reboot_to_recovery).setOnClickListener(this); findViewById(R.id.btn_reboot_to_bootloader).setOnClickListener(this); tvAboutDevice.setText("isRoot: " + DeviceUtils.isDeviceRooted() + "\ngetSDKVersion: " + DeviceUtils.getSDKVersion() + "\ngetAndroidID: " + DeviceUtils.getAndroidID() + "\ngetMacAddress: " + DeviceUtils.getMacAddress()
193,506
import java.util.Locale; public class CrashUtils implements Thread.UncaughtExceptionHandler { private volatile static CrashUtils mInstance; private UncaughtExceptionHandler mHandler; <BUG>private boolean mInitialized; private String crashDir; private String versionName; private int versionCode; private CrashUtils() {</BUG> }
import java.util.Locale; public class CrashUtils implements Thread.UncaughtExceptionHandler { private volatile static CrashUtils mInstance; private UncaughtExceptionHandler mHandler; private boolean mInitialized; private String crashDir; private String versionName; private int versionCode; private CrashUtils() { }
193,507
import android.app.Activity; import android.app.KeyguardManager; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.res.Configuration; <BUG>import android.graphics.Bitmap; import android.util.DisplayMetrics;</BUG> import android.view.Surface; import android.view.View; import android.view.WindowManager;
import android.app.Activity; import android.app.KeyguardManager; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; import android.provider.Settings; import android.util.DisplayMetrics; import android.view.Surface; import android.view.View; import android.view.WindowManager;
193,508
+ "\nisAvailableByPing: " + NetworkUtils.isAvailableByPing() + "\ngetDataEnabled: " + NetworkUtils.getDataEnabled() + "\nis4G: " + NetworkUtils.is4G() + "\ngetWifiEnabled: " + NetworkUtils.getWifiEnabled() + "\nisWifiConnected: " + NetworkUtils.isWifiConnected() <BUG>+ "\nisWifiAvailable: " + NetworkUtils.isWifiAvailable() + "\ngetNetworkOperatorName: " + NetworkUtils.getNetworkOperatorName()</BUG> + "\ngetNetworkTypeName: " + NetworkUtils.getNetworkType() + "\ngetIPAddress: " + NetworkUtils.getIPAddress(true) + "\ngetDomainAddress: " + NetworkUtils.getDomainAddress("baidu.com")
+ "\nisAvailableByPing: " + NetworkUtils.isAvailableByPing() + "\ngetDataEnabled: " + NetworkUtils.getDataEnabled() + "\nis4G: " + NetworkUtils.is4G() + "\ngetWifiEnabled: " + NetworkUtils.getWifiEnabled() + "\nisWifiConnected: " + NetworkUtils.isWifiConnected() + "\nisWifiAvailable: " + NetworkUtils.isWifiAvailable() + "\nisAvailableByPing: " + NetworkUtils.isAvailableByPing() + "\ngetNetworkOperatorName: " + NetworkUtils.getNetworkOperatorName() + "\ngetNetworkTypeName: " + NetworkUtils.getNetworkType() + "\ngetIPAddress: " + NetworkUtils.getIPAddress(true) + "\ngetDomainAddress: " + NetworkUtils.getDomainAddress("baidu.com")
193,509
while (Math.abs(prev_dist) < c_epsilon) { ++corners_skipped_before; int curr_no = p_start_no - corners_skipped_before; if (curr_no < 0) return null; <BUG>prev_corner = p_line_arr[curr_no].intersection_approx(p_line_arr[curr_no + 1]); </BUG> prev_dist = translate_line.distance_signed(prev_corner); } double next_dist = translate_line.distance_signed(next_corner);
while (Math.abs(prev_dist) < c_epsilon) { ++corners_skipped_before; int curr_no = p_start_no - corners_skipped_before; if (curr_no < 0) return null; prev_corner = p_line_arr.get(curr_no).intersection_approx(p_line_arr.get(curr_no + 1)); prev_dist = translate_line.distance_signed(prev_corner); } double next_dist = translate_line.distance_signed(next_corner);
193,510
</BUG> { return null; } <BUG>next_corner = p_line_arr[curr_no].intersection_approx(p_line_arr[curr_no + 1]); </BUG> next_dist = translate_line.distance_signed(next_corner); } if (Signum.of(prev_dist) != Signum.of(next_dist)) {
double next_dist = translate_line.distance_signed(next_corner); while (Math.abs(next_dist) < c_epsilon) { ++corners_skipped_after; int curr_no = p_start_no + 3 + corners_skipped_after; if (curr_no >= p_line_arr.size() - 2) { return null; } next_corner = p_line_arr.get(curr_no).intersection_approx(p_line_arr.get(curr_no + 1)); next_dist = translate_line.distance_signed(next_corner); } if (Signum.of(prev_dist) != Signum.of(next_dist)) {
193,511
if ( curr_prev_corner.is_NaN() ) return null; <BUG>PlaLineInt curr_translate_line = p_line_arr[p_start_no + 1 - index]; </BUG> double curr_translate_dist = curr_translate_line.distance_signed(curr_prev_corner); prev_translated_line = curr_translate_line.translate(-curr_translate_dist); <BUG>curr_lines[p_start_no + 1 - index] = prev_translated_line; </BUG> } prev_translated_line = new_line; for (int index = 0; index < corners_skipped_after; ++index)
if ( curr_prev_corner.is_NaN() ) return null; PlaLineInt curr_translate_line = p_line_arr.get(p_start_no + 1 - index); double curr_translate_dist = curr_translate_line.distance_signed(curr_prev_corner); prev_translated_line = curr_translate_line.translate(-curr_translate_dist); curr_lines.set(p_start_no + 1 - index, prev_translated_line); } prev_translated_line = new_line; for (int index = 0; index < corners_skipped_after; ++index)
193,512
} prev_translated_line = new_line; for (int index = 0; index < corners_skipped_after; ++index) { int next_line_no = p_start_no + 3 + corners_skipped_after; <BUG>PlaPointFloat curr_next_corner = prev_translated_line.intersection_approx(curr_lines[next_line_no]); </BUG> if ( curr_next_corner.is_NaN() ) return null; <BUG>PlaLineInt curr_translate_line = p_line_arr[p_start_no + 3 + index]; </BUG> double curr_translate_dist = curr_translate_line.distance_signed(curr_next_corner);
} prev_translated_line = new_line; for (int index = 0; index < corners_skipped_after; ++index) { int next_line_no = p_start_no + 3 + corners_skipped_after; PlaPointFloat curr_next_corner = prev_translated_line.intersection_approx(curr_lines.get(next_line_no)); if ( curr_next_corner.is_NaN() ) return null; PlaLineInt curr_translate_line = p_line_arr.get(p_start_no + 3 + index); double curr_translate_dist = curr_translate_line.distance_signed(curr_next_corner);
193,513
if ( curr_next_corner.is_NaN() ) return null; <BUG>PlaLineInt curr_translate_line = p_line_arr[p_start_no + 3 + index]; </BUG> double curr_translate_dist = curr_translate_line.distance_signed(curr_next_corner); prev_translated_line = curr_translate_line.translate(-curr_translate_dist); <BUG>curr_lines[p_start_no + 3 + index] = prev_translated_line; </BUG> } Polyline tmp = new Polyline(curr_lines); <BUG>if (tmp.plaline_len() == curr_lines.length) </BUG> {
if ( curr_next_corner.is_NaN() ) return null; PlaLineInt curr_translate_line = p_line_arr.get(p_start_no + 3 + index); double curr_translate_dist = curr_translate_line.distance_signed(curr_next_corner); prev_translated_line = curr_translate_line.translate(-curr_translate_dist); curr_lines.set(p_start_no + 3 + index, prev_translated_line); } Polyline tmp = new Polyline(curr_lines); if (tmp.plaline_len() == curr_lines.size()) {
193,514
check_ok = r_board.check_trace(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, contact_pins); } delta_dist /= 2; if (check_ok) { <BUG>result = curr_lines[p_start_no + 2]; </BUG> if (translate_dist == max_translate_dist) break; translate_dist += delta_dist; }
check_ok = r_board.check_trace(shape_to_check, curr_layer, curr_net_no_arr, curr_cl_type, contact_pins); } delta_dist /= 2; if (check_ok) { result = curr_lines.get(p_start_no + 2); if (translate_dist == max_translate_dist) break; translate_dist += delta_dist; }
193,515
translate_dist -= shorten_value; delta_dist -= shorten_value; } } if (result == null) return null; <BUG>PlaPointFloat new_prev_corner = curr_lines[p_start_no].intersection_approx(curr_lines[p_start_no + 1]); PlaPointFloat new_next_corner = curr_lines[p_start_no + 3].intersection_approx(curr_lines[p_start_no + 4]); </BUG> r_board.changed_area.join(new_prev_corner, curr_layer);
translate_dist -= shorten_value; delta_dist -= shorten_value; } } if (result == null) return null; PlaPointFloat new_prev_corner = curr_lines.get(p_start_no).intersection_approx(curr_lines.get(p_start_no + 1)); PlaPointFloat new_next_corner = curr_lines.get(p_start_no + 3).intersection_approx(curr_lines.get(p_start_no + 4)); r_board.changed_area.join(new_prev_corner, curr_layer);
193,516
for (int index = 0; index < new_lines.length - 2; ++index) </BUG> { <BUG>new_lines[index] = trace_polyline.plaline(index); </BUG> } <BUG>new_lines[new_lines.length - 2] = new_line; new_lines[new_lines.length - 1] = other_trace_line; return new Polyline(new_lines);</BUG> }
return new Polyline(new_lines); } } else if (bend) { PlaLineIntAlist check_line_arr = new PlaLineIntAlist(new_line_count); check_line_arr.add( other_prev_trace_line); check_line_arr.add( other_trace_line); for (int index = 2; index < new_line_count; ++index) { check_line_arr.add( trace_polyline.plaline(index - diff));
193,517
return size()+offset; } public PlaLineInt[] to_array() { return a_list.toArray(new PlaLineInt[size()]); <BUG>} @Override</BUG> public Iterator<PlaLineInt> iterator() { return a_list.iterator();
return size()+offset; } public PlaLineInt[] to_array() { return a_list.toArray(new PlaLineInt[size()]); } public ArrayList<PlaLineInt>to_alist() { return a_list; } @Override public Iterator<PlaLineInt> iterator() { return a_list.iterator();
193,518
public ReportElement getBase() { return base; } @Override public float print(PDDocument document, PDPageContentStream stream, int pageNumber, float startX, float startY, float allowedWidth) throws IOException { <BUG>PDPage currPage = (PDPage) document.getDocumentCatalog().getPages().get(pageNo); PDPageContentStream pageStream = new PDPageContentStream(document, currPage, true, false); </BUG> base.print(document, pageStream, pageNo, x, y, width); pageStream.close();
public ReportElement getBase() { return base; } @Override public float print(PDDocument document, PDPageContentStream stream, int pageNumber, float startX, float startY, float allowedWidth) throws IOException { PDPage currPage = document.getDocumentCatalog().getPages().get(pageNo); PDPageContentStream pageStream = new PDPageContentStream(document, currPage, PDPageContentStream.AppendMode.APPEND, false); base.print(document, pageStream, pageNo, x, y, width); pageStream.close();
193,519
public PdfTextStyle(String config) { Assert.hasText(config); String[] split = config.split(","); Assert.isTrue(split.length == 3, "config must look like: 10,Times-Roman,#000000"); fontSize = Integer.parseInt(split[0]); <BUG>font = resolveStandard14Name(split[1]); color = new Color(Integer.valueOf(split[2].substring(1), 16));</BUG> } public int getFontSize() { return fontSize;
public PdfTextStyle(String config) { Assert.hasText(config); String[] split = config.split(","); Assert.isTrue(split.length == 3, "config must look like: 10,Times-Roman,#000000"); fontSize = Integer.parseInt(split[0]); font = getFont(split[1]); color = new Color(Integer.valueOf(split[2].substring(1), 16)); } public int getFontSize() { return fontSize;
193,520
import org.apache.pdfbox.pdmodel.PDDocument; <BUG>import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; import org.apache.pdfbox.pdmodel.font.PDFont;</BUG> import org.springframework.util.StringUtils; <BUG>import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map;</BUG> public class ReportRichTextBox extends ReportTextBox { public ReportRichTextBox(PdfTextStyle textConfig, float lineDistance, String text) {
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPageContentStream; import org.springframework.util.StringUtils; public class ReportRichTextBox extends ReportTextBox { public ReportRichTextBox(PdfTextStyle textConfig, float lineDistance, String text) {
193,521
package cc.catalysts.boot.report.pdf.elements; import org.apache.pdfbox.pdmodel.PDDocument; <BUG>import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; import java.io.IOException;</BUG> import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList;
package cc.catalysts.boot.report.pdf.elements; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPageContentStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList;
193,522
package cc.catalysts.boot.report.pdf.elements; import cc.catalysts.boot.report.pdf.config.PdfTextStyle; import cc.catalysts.boot.report.pdf.utils.ReportAlignType; import org.apache.pdfbox.pdmodel.PDPageContentStream; <BUG>import org.apache.pdfbox.pdmodel.font.PDFont; import org.slf4j.Logger;</BUG> import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; import java.io.IOException;
package cc.catalysts.boot.report.pdf.elements; import cc.catalysts.boot.report.pdf.config.PdfTextStyle; import cc.catalysts.boot.report.pdf.utils.ReportAlignType; import org.apache.pdfbox.pdmodel.PDPageContentStream; import org.apache.pdfbox.pdmodel.font.PDFont; import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.util.Matrix; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; import java.io.IOException;
193,523
addTextSimple(stream, textConfig, textX, nextLineY, ""); return nextLineY; } try { <BUG>String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, fixedText); </BUG> float x = calculateAlignPosition(textX, align, textConfig, allowedWidth, split[0]); if (!underline) { addTextSimple(stream, textConfig, x, nextLineY, split[0]); } else {
addTextSimple(stream, textConfig, textX, nextLineY, ""); return nextLineY; } try { String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, text); float x = calculateAlignPosition(textX, align, textConfig, allowedWidth, split[0]); if (!underline) { addTextSimple(stream, textConfig, x, nextLineY, split[0]); } else {
193,524
public static void addTextSimple(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) { try { stream.setFont(textConfig.getFont(), textConfig.getFontSize()); stream.setNonStrokingColor(textConfig.getColor()); stream.beginText(); <BUG>stream.newLineAtOffset(textX, textY); stream.showText(text);</BUG> } catch (Exception e) { LOG.warn("Could not add text: " + e.getClass() + " - " + e.getMessage()); }
public static void addTextSimple(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) { try { stream.setFont(textConfig.getFont(), textConfig.getFontSize()); stream.setNonStrokingColor(textConfig.getColor()); stream.beginText(); stream.setTextMatrix(new Matrix(1,0,0,1, textX, textY)); stream.showText(text); } catch (Exception e) { LOG.warn("Could not add text: " + e.getClass() + " - " + e.getMessage()); }
193,525
public static void addTextSimpleUnderlined(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) { addTextSimple(stream, textConfig, textX, textY, text); try { float lineOffset = textConfig.getFontSize() / 8F; stream.setStrokingColor(textConfig.getColor()); <BUG>stream.setLineWidth(0.5F); stream.drawLine(textX, textY - lineOffset, textX + getTextWidth(textConfig.getFont(), textConfig.getFontSize(), text), textY - lineOffset); </BUG> stream.stroke(); } catch (IOException e) {
public static void addTextSimpleUnderlined(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) { addTextSimple(stream, textConfig, textX, textY, text); try { float lineOffset = textConfig.getFontSize() / 8F; stream.setStrokingColor(textConfig.getColor()); stream.setLineWidth(0.5F); stream.moveTo(textX, textY - lineOffset); stream.lineTo(textX + getTextWidth(textConfig.getFont(), textConfig.getFontSize(), text), textY - lineOffset); stream.stroke(); } catch (IOException e) {
193,526
list.add(text.length()); return list; } public static String[] splitText(PDFont font, int fontSize, float allowedWidth, String text) { String endPart = ""; <BUG>String shortenedText = text; List<String> breakSplitted = Arrays.asList(shortenedText.split("(\\r\\n)|(\\n)|(\\n\\r)")).stream().collect(Collectors.toList()); if (breakSplitted.size() > 1) {</BUG> String[] splittedFirst = splitText(font, fontSize, allowedWidth, breakSplitted.get(0)); StringBuilder remaining = new StringBuilder(splittedFirst[1] == null ? "" : splittedFirst[1] + "\n");
list.add(text.length()); return list; } public static String[] splitText(PDFont font, int fontSize, float allowedWidth, String text) { String endPart = ""; List<String> breakSplitted = Arrays.asList(text.split("(\\r\\n)|(\\n)|(\\n\\r)")).stream().collect(Collectors.toList()); if (breakSplitted.size() > 1) { String[] splittedFirst = splitText(font, fontSize, allowedWidth, breakSplitted.get(0)); StringBuilder remaining = new StringBuilder(splittedFirst[1] == null ? "" : splittedFirst[1] + "\n");
193,527
StringBuilder remaining = new StringBuilder(splittedFirst[1] == null ? "" : splittedFirst[1] + "\n"); breakSplitted.stream().skip(1).forEach(s -> remaining.append(s + "\n")); remaining.deleteCharAt(remaining.length() - 1); return new String[]{splittedFirst[0], remaining.toString()}; } <BUG>if (getTextWidth(font, fontSize, shortenedText) <= allowedWidth && shortenedText.indexOf((char) 13) == -1) { return new String[]{shortenedText, null}; }</BUG> boolean cleanSplit = true; <BUG>List<Integer> indexes = getWrapableIndexes(shortenedText); int start = 0;</BUG> int j = indexes.size() - 1;
StringBuilder remaining = new StringBuilder(splittedFirst[1] == null ? "" : splittedFirst[1] + "\n"); breakSplitted.stream().skip(1).forEach(s -> remaining.append(s + "\n")); remaining.deleteCharAt(remaining.length() - 1); return new String[]{splittedFirst[0], remaining.toString()}; } if (getTextWidth(font, fontSize, text) <= allowedWidth && text.indexOf((char) 13) == -1) { return new String[]{text, null}; } boolean cleanSplit = true; List<Integer> indexes = getWrapableIndexes(text); int start = 0; int j = indexes.size() - 1;
193,528
boolean cleanSplit = true; <BUG>List<Integer> indexes = getWrapableIndexes(shortenedText); int start = 0;</BUG> int j = indexes.size() - 1; int end = indexes.get(j); <BUG>int lineBreakPos = shortenedText.indexOf(10); if (lineBreakPos != -1 && getTextWidth(font, fontSize, shortenedText.substring(start, lineBreakPos)) <= allowedWidth) { end = lineBreakPos;</BUG> } else { <BUG>while (getTextWidth(font, fontSize, shortenedText.substring(start, end)) > allowedWidth) { if (j == 0) {</BUG> cleanSplit = false;
boolean cleanSplit = true; List<Integer> indexes = getWrapableIndexes(text); int start = 0; int j = indexes.size() - 1; int end = indexes.get(j); int lineBreakPos = text.indexOf(10); if (lineBreakPos != -1 && getTextWidth(font, fontSize, text.substring(start, lineBreakPos)) <= allowedWidth) { end = lineBreakPos; } else { while (getTextWidth(font, fontSize, text.substring(start, end)) > allowedWidth) { if (j == 0) { cleanSplit = false;
193,529
package dr.inference.operators; import dr.inference.model.Bounds; import dr.inference.model.Parameter; public interface Scalable { <BUG>int scale(double factor, int nDims) throws OperatorFailedException; String getName();</BUG> public class Default implements Scalable { private final Parameter parameter; public Default(Parameter p) {
package dr.inference.operators; import dr.inference.model.Bounds; import dr.inference.model.Parameter; public interface Scalable { int scale(double factor, int nDims); String getName(); public class Default implements Scalable { private final Parameter parameter; public Default(Parameter p) {
193,530
final int dim = variable.getSize(); if (scaleAllIndependently) { logq = 0; for (int i = 0; i < dim; i++) { final double scaleOne = (scaleFactor + (MathUtils.nextDouble() * ((1.0 / scaleFactor) - scaleFactor))); <BUG>final double value = scaleOne * variable.getValue(i); logq -= Math.log(scaleOne); if (value < bounds.getLowerLimit(i) || value > bounds.getUpperLimit(i)) { return Double.NEGATIVE_INFINITY; }</BUG> variable.setValue(i, value);
final int dim = variable.getSize(); if (scaleAllIndependently) { logq = 0; for (int i = 0; i < dim; i++) { final double scaleOne = (scaleFactor + (MathUtils.nextDouble() * ((1.0 / scaleFactor) - scaleFactor))); final double offset = bounds.getLowerLimit(i); final double value = ((variable.getValue(i) - offset) * scaleOne) + offset; logq -= Math.log(scaleOne); if (value > bounds.getUpperLimit(i)) { throw new RuntimeException("proposed value greater than upper bound"); }
193,531
variable.setValue(i, variable.getValue(i) * scale); </BUG> } for (int i = 0; i < dim; i++) { <BUG>if (variable.getValue(i) < variable.getBounds().getLowerLimit(i) || variable.getValue(i) > variable.getBounds().getUpperLimit(i)) { return Double.NEGATIVE_INFINITY; }</BUG> }
} else if (scaleAll) { if (degreesOfFreedom > 0) logq = -degreesOfFreedom * Math.log(scale); else logq = (dim - 2) * Math.log(scale); for (int i = 0; i < dim; i++) { final double offset = bounds.getLowerLimit(i); variable.setValue(i, ((variable.getValue(i) - offset) * scale) + offset); } for (int i = 0; i < dim; i++) { if (variable.getValue(i) > variable.getBounds().getUpperLimit(i)) { throw new RuntimeException("proposed value greater than upper bound"); } }
193,532
return Double.NEGATIVE_INFINITY; } } else { index = MathUtils.nextInt(dim); } <BUG>final double oldValue = variable.getValue(index); if (oldValue == 0) {</BUG> Logger.getLogger("dr.inference").severe("The " + ScaleOperatorParser.SCALE_OPERATOR + " for " + variable.getVariableName()
return Double.NEGATIVE_INFINITY; } } else { index = MathUtils.nextInt(dim); } final double oldValue = variable.getValue(index); final double offset = bounds.getLowerLimit(index); if (oldValue == 0) { Logger.getLogger("dr.inference").severe("The " + ScaleOperatorParser.SCALE_OPERATOR + " for " + variable.getVariableName()
193,533
+ " has failed since the parameter has a value of 0.0." + "\nTo fix this problem, initalize the value of " + variable.getVariableName() + " to be a positive real number" ); } <BUG>final double newValue = scale * oldValue; if (newValue < bounds.getLowerLimit(index) || newValue > bounds.getUpperLimit(index)) { return Double.NEGATIVE_INFINITY; }</BUG> variable.setValue(index, newValue);
+ " has failed since the parameter has a value of 0.0." + "\nTo fix this problem, initalize the value of " + variable.getVariableName() + " to be a positive real number" ); } final double newValue = ((oldValue - offset) * scale) + offset; if (newValue > bounds.getUpperLimit(index)) { throw new RuntimeException("proposed value greater than upper bound"); } variable.setValue(index, newValue);
193,534
<BUG>package org.ff4j.web; import java.util.HashMap;</BUG> import java.util.HashSet; import java.util.Map; import java.util.Set;
package org.ff4j.web; import static org.ff4j.web.FF4jWebConstants.ROLE_READ; import static org.ff4j.web.FF4jWebConstants.ROLE_WRITE; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set;
193,535
import java.util.HashMap;</BUG> import java.util.HashSet; import java.util.Map; import java.util.Set; import org.ff4j.FF4j; <BUG>import static org.ff4j.web.FF4jWebConstants.*; public class ApiConfig implements FF4JProvider { </BUG> private FF4j ff4j; private boolean authenticate = false;
package org.ff4j.web; import static org.ff4j.web.FF4jWebConstants.ROLE_READ; import static org.ff4j.web.FF4jWebConstants.ROLE_WRITE; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.ff4j.FF4j; public class ApiConfig implements FF4jProvider { private FF4j ff4j; private boolean authenticate = false;