我在Grails有一个应用程序.我使用Hibernate访问数据库(按照标准grails规则)我使用MySql并且网站工作且稳定(6个月).
我正在进行负载测试,最近发现数据库在负载时拒绝连接.
使用MySQL Server 5,我可以看到连接的线程在20左右徘徊.我想跳到11到30之间.
mysql> show status like '%con%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| Aborted_connects | 72 |
| Connections | 65539 |
| Max_used_connections | 101 |
| Ssl_client_connects | 0 |
| Ssl_connect_renegotiates | 0 |
| Ssl_finished_connects | 0 |
| Threads_connected | 1 |
+--------------------------+-------+
7 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
我的数据库配置是标准的.(MySql服务器在本地安装,未显示)
dataSource {
pooled = false
driverClassName = "com.mysql.jdbc.Driver"
username = "username"
password = "secret"
maxIdle = 15
maxActive = 100 …Run Code Online (Sandbox Code Playgroud) 我在一个循环(按县名)中使用以下ggplot2 v0.9 scale_x_continious逻辑,试图在具有相同x标度的单独图上绘制每个县的数据.
MaxDays=365*3;
p <- p + scale_x_continuous(limits=c(0,MaxDays))
p <- p + scale_x_continuous(breaks=seq(0,MaxDays,60))
Run Code Online (Sandbox Code Playgroud)
如果所有县都有数据> = MaxDate,那么逻辑很有效.但是,如果天数小于MaxDate,则图表x比例不均匀(即比如0 - 720天)
如何将scalse设置为绝对值而不是限制值?
任何援助都将受到极大的赞赏
############################################
### Sample Data Below
############################################
# County 1 data
Days=seq(1,30,1)
Qty=Days*10
County=rep("Washington",length(Days))
df1=data.frame(County, Qty, Days)
# County 2 data
Days=seq(1,15,1)
Qty=Days*20
County=rep("Jefferson",length(Days))
df2=data.frame(County, Qty, Days)
# County 1 and 2 data
df3=rbind(df1,df2)
# calculate ranges for x scales
yrng=range(df3$Qty)
xrng=range(df3$Days)
# Scatter Plots
fname=paste("C:/test",".pdf",sep="");
pdf(fname,10,8,onefile=TRUE,paper="a4r");
p <- ggplot()
cnty=unique(df3$County)
n=length(unique(df3$County))
for (i in 1:n){
df4<-subset(df3, County==cnty[i])
p <- …Run Code Online (Sandbox Code Playgroud) 我试图ImageView通过搜索谷歌和这里的SO 来开发自定义.
除非我尝试使用mdetector.getFocusX()和缩放画布,否则一切正常mdetector.getFocusY().
缩放正常,但拖动计算搞砸了.
当我canvas.scale(mScaleFactor,mScaleFactor,gx,gy)在下面的代码中使用时,拖动会在整个地方发生,并且可以看到后面的黑屏.
我想限制拖动到屏幕边界.
在我的代码中,绑定计算适用于放大,当canvas.scale(mScaleFactor,mScaleFactor)ie:它在(0,0)不使用轴点的情况下缩放时正常工作.
这是代码:
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.ImageView;
/* @description : Custom View Zoom
*
*/
public class ZoomView extends ImageView {
// Maximum and Minimum Zoom
private static float MIN_ZOOM = 1.0f;
private static float MAX_ZOOM = 3.0f;
//Different Operation to be used
private final int NONE_OPERATION=0;
private final int DRAG_OPERATION=1; …Run Code Online (Sandbox Code Playgroud) 遵循Microsoft规模指南,其中有一部分说:
在设计固定布局时,首先要设计基线分辨率的布局:1024x768和1366x768.
关于这一点,我有以下问题:
是否可以为两个宽高比定义两个固定布局(两者都用于ViewBox缩放到该宽高比中的每个分辨率),以便它们可以根据屏幕的宽高比自动更改?也许在填充模式和全屏模式之间切换也会改变宽高比?
我想将变量的值表示为R中散点中的点的颜色.
x <- rnorm(100) + 5
y <- rnorm(100) + 5
plot(x, y)
Run Code Online (Sandbox Code Playgroud)
在这里,我想使用变量作为着色的输入.但是,如果我尝试
plot(x, y, col = x)
Run Code Online (Sandbox Code Playgroud)
我很奇怪,可能很明显.现在我可以得到我想要的东西:
x_norm = (x - min(x)) / (max(x) - min(x))
col_fun <- colorRamp(c("blue", "red"))
rgb_cols <- col_fun(x_norm)
cols <- rgb(rgb_cols, maxColorValue = 256)
plot(x, y, col = cols)
Run Code Online (Sandbox Code Playgroud)

但这看起来有点复杂,并且要使用NA或NaN值,例如将它们设为黑色作为颜色,就不那么容易了.为了我.有一种简单的方法可以做到这一点,我忽略了吗?
我试图扩大css精灵像素艺术图像,并希望完全禁用抗锯齿/图像平滑.
根据这篇文章:缩放图像时禁用抗锯齿我尝试了以下css
image-rendering: optimizeSpeed;
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
-ms-interpolation-mode: nearest-neighbor;
Run Code Online (Sandbox Code Playgroud)
它的工作方式与我想要的一样,但是在Chrome和IE浏览器中它有点帮助,但仍然会出现一些图像插值/平滑/抗锯齿.
我不想使用canvas元素,而只是坚持使用CSS背景图像sprite.
有没有办法在其他浏览器中实现与"-moz-crisp-edges"相同的结果?
我想在a上显示一个大图像,UIWebView以便用户在看到这个屏幕时看到完整的图像.webview应采用这样的比例,即它占据图像的整个宽度并根据可用的屏幕宽度进行调整(图像的比例宽度/高度应保持不变).所以webview必须缩小.
因此我使用了这个scalesPageToFit属性.图像大约为3900x2613,但您也可以使用其他大图像.有趣的是,用户无法手动完全缩小以查看整个图像.
现在我做了一个测试项目并尝试了不同的解决方案来加载图像(本地,Web资源,NSData,......).现在我在C#中为您提供一些示例代码.
本地:
webView = new UIWebView (View.Bounds);
View.AddSubview (webView);
string filePath = NSBundle.MainBundle.PathForResource ("sample", "jpg");
NSUrl fileURL = new NSUrl (filePath);
webView.LoadRequest (new NSUrlRequest (fileURL));
webView.ScalesPageToFit = true;
Run Code Online (Sandbox Code Playgroud)
或者来自网络资源:
webView = new UIWebView (View.Bounds);
webView.ScalesPageToFit = true;
View.AddSubview (webView);
webView.LoadRequest (new NSUrlRequest (new NSUrl("http://www.libpng.org/pub/png/img_png/16million-pschmidt.png")));
Run Code Online (Sandbox Code Playgroud)
或者使用本地图像和HTML:
webView = new UIWebView ();
webView.TranslatesAutoresizingMaskIntoConstraints = false;
webView.ScalesPageToFit = true;
View.AddSubview (webView);
NSMutableDictionary viewsDictionary = new NSMutableDictionary ();
viewsDictionary ["webView"] = webView;
View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|[webView]|", (NSLayoutFormatOptions)0, …Run Code Online (Sandbox Code Playgroud) 我最近开始涉足矢量图像和动画.但是,一旦路径变形动画完成,我希望能够在所有方向上均匀地缩放我的图像.
我尝试过在任何地方应用pivotX和Y但它似乎没有什么区别.
我怎样才能实现中心规模,而不仅仅是从左到右扩展?
test_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/test_image"
android:layout_gravity="center"
android:src="@drawable/animated_logo"
android:layout_width="200dp"
android:layout_height="200dp" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
animated_logo.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/closed_logo" >
<target
android:animation="@anim/scale"
android:name="logo"/>
</animated-vector>
Run Code Online (Sandbox Code Playgroud)
scale.anim
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:duration="1500"
android:propertyName="scaleX"
android:valueFrom="1.0"
android:valueTo="10"
android:valueType="floatType"/>
<objectAnimator
android:duration="1500"
android:propertyName="scaleY"
android:valueFrom="1.0"
android:valueTo="10"
android:valueType="floatType"/>
Run Code Online (Sandbox Code Playgroud)
closed_logo.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="75"
android:viewportHeight="75"
android:width="1000dp"
android:height="1000dp">
<group android:name="logo">
<path
android:name="box"
android:fillColor="#DADADA"
android:pathData="M65.5,54.4L11.1,65.5L0,11.1L54.4,0L65.5,54.4z"/>
<path
android:name="bottom_left"
android:fillColor="#47A89C"
android:pathData="M 7.1,22.2 l 15.2,36.0 l 10.4,-25.6 L 32.699997,32.6 L 7.1,22.2 L 7.1,22.2z" />
<path …Run Code Online (Sandbox Code Playgroud) 我已经为ImageView创建了比例动画。我只想在x方向上缩放它。但是,当我运行该应用程序时,视图仅从scaleX = 0弹出到scaleX = 1,而没有任何动画。
我尝试了不同的方法来为ImageView设置动画,但是始终会出现相同的问题。这是我的代码:
Java:
line.animate()
.scaleXBy(0)
.scaleX(1)
.setDuration(750);
Run Code Online (Sandbox Code Playgroud)
Xml:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/line"
android:adjustViewBounds="true"
android:id="@+id/line"/>
Run Code Online (Sandbox Code Playgroud)
我也尝试在Java中使用以下内容:
Animation scaleLine = new ScaleAnimation(0f, 1f, 1f, 1f);
scaleLine.setFillAfter(true);
scaleLine.setDuration(750);
line.startAnimation(scaleLine);
scaleLine.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
line.setScaleX(1);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
Run Code Online (Sandbox Code Playgroud)
你们有什么建议吗?谢谢!
我知道如何将按钮缩放到一个确定的值,但是只要用户触摸它,就有办法增加/减少每次按钮的大小吗?像这样的东西:
Button myButton = (Button)findViewById(R.id.myButton);
myButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// Some timer action here or is there a better way?
v.setScaleX(v.getScaleX() + 0.1f);
v.setScaleY(v.getScaleY() + 0.1f);
return true;
}
else if(event.getAction() == MotionEvent.ACTION_UP) {
v.setScaleX(1);
v.setScaleY(1);
return true;
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
其他想法 - 不起作用:
myButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Timer timer = new Timer();
TimerTask …Run Code Online (Sandbox Code Playgroud)